Skip to content

Commit

Permalink
[mcs] Resize identifier buffer in all cases. Fixes #28292
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Mar 25, 2015
1 parent db2a67f commit de86cb9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mcs/mcs/cs-tokenizer.cs
Expand Up @@ -3931,6 +3931,9 @@ int TokenizeInterpolatedString ()
if (pos == value_builder.Length)
Array.Resize (ref value_builder, pos * 2);

if (pos == value_builder.Length)
Array.Resize (ref value_builder, pos * 2);

value_builder [pos++] = (char)ch;
ch = surrogate;
}
Expand All @@ -3941,6 +3944,9 @@ int TokenizeInterpolatedString ()
}

++col;
if (pos == value_builder.Length)
Array.Resize (ref value_builder, pos * 2);

value_builder[pos++] = (char) ch;
}
}
Expand Down
5 changes: 5 additions & 0 deletions mcs/tests/test-interpolation-05.cs
Expand Up @@ -8,6 +8,11 @@ void Test1 ()
Console.WriteLine(b ? $"{1:0.00}" : $"bar");
}

void Test2 ()
{
Console.WriteLine($"This should work but the compiler explodes if the string is too long!");
}

public static void Main()
{
}
Expand Down
3 changes: 3 additions & 0 deletions mcs/tests/ver-il-net_4_5.xml
Expand Up @@ -66692,6 +66692,9 @@
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
<method name="Void Test2()" attrs="129">
<size>12</size>
</method>
</type>
</test>
<test name="test-iter-01.cs">
Expand Down

0 comments on commit de86cb9

Please sign in to comment.