1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

XmlElement: Fix rare crash when parsing truncated escape sequences

This commit is contained in:
reuk 2021-02-17 11:44:58 +00:00
parent 64b9366e8f
commit c6280f7b8a
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -684,7 +684,7 @@ void XmlDocument::readEntity (String& result)
}
else if (*input == '#')
{
int charCode = 0;
int64_t charCode = 0;
++input;
if (*input == 'x' || *input == 'X')
@ -712,15 +712,26 @@ void XmlDocument::readEntity (String& result)
{
int numChars = 0;
while (input[0] != ';')
for (;;)
{
const auto firstChar = input[0];
if (firstChar == 0)
{
setLastError ("unexpected end of input", true);
return;
}
if (firstChar == ';')
break;
if (++numChars > 12)
{
setLastError ("illegal escape sequence", true);
break;
}
charCode = charCode * 10 + ((int) input[0] - '0');
charCode = charCode * 10 + ((int) firstChar - '0');
++input;
}