Skip to content

Commit d795e5f

Browse files
committed
Check if string is length 0 and throw instead of stack overflowing
1 parent daa3d18 commit d795e5f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sources/SilkTouch/SilkTouch/Naming/NameUtils.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ public static string Prettify(
7171
.Pascalize()
7272
.Where(x => char.IsLetter(x) || char.IsNumber(x))
7373
);
74+
75+
if (ret.Length == 0)
76+
{
77+
throw new InvalidOperationException($"Failed to prettify string: {str}");
78+
}
79+
7480
var retSpan = ret.AsSpan();
7581
if (!allowAllCaps && retSpan.IndexOfAny(NotUppercase) == -1)
7682
{

0 commit comments

Comments
 (0)