Add NULL-terminator the string passed to strtol.

This is actually expected by the function although it was apparently
working in GCC without the terminator, it breaks (at least some) clang
versions.

(cherry picked from commit 2f91e250f6)
This commit is contained in:
Fabio Alessandrelli 2019-07-08 17:15:10 +02:00 committed by Rémi Verschelde
parent 6aaca81d2b
commit 41fe1bd887
1 changed files with 1 additions and 1 deletions

View File

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