From 12529442514aca827d0daea0bfed42ae5db6c99f Mon Sep 17 00:00:00 2001 From: Isaac Miell Date: Wed, 17 Feb 2016 02:41:09 +1030 Subject: [PATCH] Better null checks in string validation functions This fixes an exception when pressing "Ok" on the "Go to Address" input prompt in the Hex Editor with an empty string --- BizHawk.Common/Extensions/StringExtensions.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/BizHawk.Common/Extensions/StringExtensions.cs b/BizHawk.Common/Extensions/StringExtensions.cs index 8b4dc857ca..93db8236aa 100644 --- a/BizHawk.Common/Extensions/StringExtensions.cs +++ b/BizHawk.Common/Extensions/StringExtensions.cs @@ -86,7 +86,7 @@ namespace BizHawk.Common.StringExtensions /// public static bool IsUnsigned(this string str) { - if (str == null) + if (string.IsNullOrWhiteSpace(str)) { return false; } @@ -107,7 +107,7 @@ namespace BizHawk.Common.StringExtensions /// public static bool IsSigned(this string str) { - if (str == null) + if (string.IsNullOrWhiteSpace(str)) { return false; } @@ -128,7 +128,7 @@ namespace BizHawk.Common.StringExtensions /// public static bool IsHex(this string str) { - if (str == null) + if (string.IsNullOrWhiteSpace(str)) { return false; } @@ -154,7 +154,7 @@ namespace BizHawk.Common.StringExtensions /// public static bool IsBinary(this string str) { - if (str == null) + if (string.IsNullOrWhiteSpace(str)) { return false; } @@ -175,7 +175,7 @@ namespace BizHawk.Common.StringExtensions /// public static bool IsFixedPoint(this string str) { - if (str == null) + if (string.IsNullOrWhiteSpace(str)) { return false; } @@ -197,7 +197,7 @@ namespace BizHawk.Common.StringExtensions /// public static bool IsFloat(this string str) { - if (str == null) + if (string.IsNullOrWhiteSpace(str)) { return false; } @@ -220,7 +220,7 @@ namespace BizHawk.Common.StringExtensions /// public static string OnlyBinary(this string raw) { - if (raw == null) + if (string.IsNullOrWhiteSpace(raw)) { return string.Empty; } @@ -243,7 +243,7 @@ namespace BizHawk.Common.StringExtensions /// public static string OnlyUnsigned(this string raw) { - if (raw == null) + if (string.IsNullOrWhiteSpace(raw)) { return string.Empty; } @@ -267,7 +267,7 @@ namespace BizHawk.Common.StringExtensions /// public static string OnlySigned(this string raw) { - if (raw == null) + if (string.IsNullOrWhiteSpace(raw)) { return string.Empty; } @@ -298,7 +298,7 @@ namespace BizHawk.Common.StringExtensions /// public static string OnlyHex(this string raw) { - if (raw == null) + if (string.IsNullOrWhiteSpace(raw)) { return string.Empty; } @@ -322,7 +322,7 @@ namespace BizHawk.Common.StringExtensions /// public static string OnlyFixedPoint(this string raw) { - if (raw == null) + if (string.IsNullOrWhiteSpace(raw)) { return string.Empty; } @@ -357,7 +357,7 @@ namespace BizHawk.Common.StringExtensions /// public static string OnlyFloat(this string raw) { - if (raw == null) + if (string.IsNullOrWhiteSpace(raw)) { return string.Empty; }