Add short-circuit for 0-length arrays

This commit is contained in:
Matt Nadareski
2024-11-28 22:15:25 -05:00
parent 0e9ba25637
commit c06d8151e6
31 changed files with 31 additions and 31 deletions

View File

@@ -46,7 +46,7 @@ namespace SabreTools.Serialization.Wrappers
public static AACSMediaKeyBlock? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -46,7 +46,7 @@ namespace SabreTools.Serialization.Wrappers
public static BDPlusSVM? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static BFPK? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static BSP? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -52,7 +52,7 @@ namespace SabreTools.Serialization.Wrappers
public static CFB? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -79,7 +79,7 @@ namespace SabreTools.Serialization.Wrappers
public static CHD? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static CIA? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -192,7 +192,7 @@ namespace SabreTools.Serialization.Wrappers
public static GCF? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static IRD? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -96,7 +96,7 @@ namespace SabreTools.Serialization.Wrappers
public static InstallShieldCabinet? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static LinearExecutable? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static MSDOS? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static MicrosoftCabinet? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static MoPaQ? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -231,7 +231,7 @@ namespace SabreTools.Serialization.Wrappers
public static N3DS? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static NCF? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static NewExecutable? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Wrappers
public static Nitro? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Wrappers
public static PAK? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -49,7 +49,7 @@ namespace SabreTools.Serialization.Wrappers
public static PFF? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Wrappers
public static PIC? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static PKZIP? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static PlayJAudioFile? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static PlayJPlaylist? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -783,7 +783,7 @@ namespace SabreTools.Serialization.Wrappers
public static PortableExecutable? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static Quantum? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -80,7 +80,7 @@ namespace SabreTools.Serialization.Wrappers
public static SGA? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static VBSP? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -107,7 +107,7 @@ namespace SabreTools.Serialization.Wrappers
public static VPK? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Wrappers
public static WAD3? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
public static XZP? Create(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
if (data == null || data.Length == 0)
return null;
// If the offset is out of bounds