Merge pull request #30432 from Faless/fix/string_http_unescape

Add NULL-terminator the string passed to strtol.
This commit is contained in:
Rémi Verschelde 2019-07-09 08:27:19 +02:00 committed by GitHub
commit bf82daf2fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3338,7 +3338,7 @@ String String::http_unescape() const {
if ((ord1 >= '0' && ord1 <= '9') || (ord1 >= 'A' && ord1 <= 'Z')) {
CharType ord2 = ord_at(i + 2);
if ((ord2 >= '0' && ord2 <= '9') || (ord2 >= 'A' && ord2 <= 'Z')) {
char bytes[2] = { (char)ord1, (char)ord2 };
char bytes[3] = { (char)ord1, (char)ord2, 0 };
res += (char)strtol(bytes, NULL, 16);
i += 2;
}