Make string to number conversions fail on NUL char.

Contributed by Igor Munkin.
This commit is contained in:
Mike Pall
2020-02-13 17:39:51 +01:00
parent d85d6b3c1b
commit 0ad60ccbc3
4 changed files with 12 additions and 7 deletions

View File

@@ -105,7 +105,7 @@ static void lex_number(LexState *ls, TValue *tv)
lex_savenext(ls);
}
lex_save(ls, '\0');
fmt = lj_strscan_scan((const uint8_t *)sbufB(&ls->sb), tv,
fmt = lj_strscan_scan((const uint8_t *)sbufB(&ls->sb), sbuflen(&ls->sb)-1, tv,
(LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) |
(LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0));
if (LJ_DUALNUM && fmt == STRSCAN_INT) {