From 8019e70483e080f1d607f878549f2d386230de9a Mon Sep 17 00:00:00 2001 From: Sour Date: Wed, 5 Sep 2018 20:51:44 -0400 Subject: [PATCH] Debugger: Fixed crashes with TBL files when unknown characters are present in the TBL file (e.g because it was not UTF-8 encoded) --- GUI.NET/Debugger/HexBox/TblByteCharConverter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GUI.NET/Debugger/HexBox/TblByteCharConverter.cs b/GUI.NET/Debugger/HexBox/TblByteCharConverter.cs index aa0193c9..7dc0aed3 100644 --- a/GUI.NET/Debugger/HexBox/TblByteCharConverter.cs +++ b/GUI.NET/Debugger/HexBox/TblByteCharConverter.cs @@ -78,7 +78,9 @@ namespace Be.Windows.Forms do { match = false; foreach(string key in _stringList) { - if(text.StartsWith(key)) { + //Without an ordinal comparison, it's possible for an empty string to "StartsWith" a non-empty string (e.g replacement char U+FFFD) + //This causes a crash here (because key.Length > text.Length) + if(text.StartsWith(key, StringComparison.Ordinal)) { bytes.AddRange(_reverseTblRules[key].GetBytes()); text = text.Substring(key.Length); match = true;