Fixed small bugs/issues

- In 'readutf8esc' (llex.c), the overflow check must be done before
shifting the accumulator. It was working because tests were using
64-bit longs. Failed with 32-bit longs.

- In OP_FORPREP (lvm.c), avoid negating an unsigned value. Visual
Studio gives a warning for that operation, despite being well
defined in ISO C.

- In 'luaV_execute' (lvm.c), 'cond' can be defined only when needed,
like all other variables.
This commit is contained in:
Roberto Ierusalimschy
2019-03-25 10:38:56 -03:00
parent 23e6bac8a0
commit 7ceb2154ed
2 changed files with 9 additions and 5 deletions

2
llex.c
View File

@@ -334,8 +334,8 @@ static unsigned long readutf8esc (LexState *ls) {
r = gethexa(ls); /* must have at least one digit */
while ((save_and_next(ls), lisxdigit(ls->current))) {
i++;
esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large");
r = (r << 4) + luaO_hexavalue(ls->current);
esccheck(ls, r <= 0x7FFFFFFFu, "UTF-8 value too large");
}
esccheck(ls, ls->current == '}', "missing '}'");
next(ls); /* skip '}' */