Fix NullReferenceException in Obfuscate (#7589) (#7591)
authorneolithos <neolithos@outlook.com>
Fri, 27 Sep 2019 16:04:33 +0000 (18:04 +0200)
committerSamantha Houts <samhouts@users.noreply.github.com>
Fri, 27 Sep 2019 16:04:33 +0000 (09:04 -0700)
fixes #7589

Xamarin.Forms.Platform.WPF/FormsTextBox.cs

index 3dae8be..20a15ab 100644 (file)
@@ -167,9 +167,9 @@ namespace Xamarin.Forms.Platform.WPF
                string Obfuscate(string text, bool leaveLastVisible = false)
                {
                        if (!leaveLastVisible)
-                               return new string(ObfuscationCharacter, text.Length);
+                               return new string(ObfuscationCharacter, text?.Length ?? 0);
 
-                       return text.Length == 1
+                       return text == null || text.Length == 1
                                ? text
                                : new string(ObfuscationCharacter, text.Length - 1) + text.Substring(text.Length - 1, 1);
                }