From 3f8fb365a0d0a99405a04eb3baa24a285c057700 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 2 Mar 2025 14:48:12 +0300 Subject: [PATCH] Convert parsed numbers to doubles first in lj_strscan_scan Regular blua does something similar to that, and it changes how large numeric literals are parsed. It's very rare for those to be used but can still in theory cause synch issues between blua and bluajit clients --- src/bluajit/lj_strscan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/bluajit/lj_strscan.c b/src/bluajit/lj_strscan.c index 1bc8a79fe..334086768 100644 --- a/src/bluajit/lj_strscan.c +++ b/src/bluajit/lj_strscan.c @@ -442,7 +442,8 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o, int cmask = LJ_CHAR_DIGIT; int base = (opt & STRSCAN_OPT_C) && *p == '0' ? 0 : 10; const uint8_t *sp, *dp = NULL; - uint32_t dig = 0, hasdig = 0, x = 0; + uint32_t dig = 0, hasdig = 0; + uint64_t x = 0; int32_t ex = 0; /* Determine base and skip leading zeros. */ @@ -574,10 +575,7 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o, fmt = strscan_bin(sp, o, fmt, opt, ex, neg, dig); else #if LJ_INTONLY - if (fmt == STRSCAN_NUM) - setnumV(o, (lua_Number)(int32_t)(neg ? ~x+1u : x)); - else - setintV(o, (int32_t)(neg ? ~x+1u : x)); + setintV(o, (int32_t)(double)(neg ? (~x+1u) : x)); #else fmt = strscan_dec(sp, o, fmt, opt, ex, neg, dig); #endif