diff options
author | Saúl Ibarra Corretgé <s@saghul.net> | 2023-12-22 22:50:02 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-02 18:12:23 +0100 |
commit | 8bad611675163d80cd6e037d10896a0153c02d8f (patch) | |
tree | 7d2de92d75579163cf7a4c6bceace47c670d895c /lib | |
parent | 581c826222dbd507a9642ba5ad03a08885093bce (diff) | |
download | chawan-8bad611675163d80cd6e037d10896a0153c02d8f.tar.gz |
Fix UB in js_dtoa1
Diffstat (limited to 'lib')
-rw-r--r-- | lib/quickjs/quickjs.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c index cb7d7dbe..d23d25c3 100644 --- a/lib/quickjs/quickjs.c +++ b/lib/quickjs/quickjs.c @@ -11594,8 +11594,10 @@ static void js_dtoa1(char *buf, double d, int radix, int n_digits, int flags) } else if (flags == JS_DTOA_VAR_FORMAT) { int64_t i64; char buf1[70], *ptr; + if (d > (double)MAX_SAFE_INTEGER || d < (double)-MAX_SAFE_INTEGER) + goto generic_conv; i64 = (int64_t)d; - if (d != i64 || i64 > MAX_SAFE_INTEGER || i64 < -MAX_SAFE_INTEGER) + if (d != i64) goto generic_conv; /* fast path for integers */ ptr = i64toa(buf1 + sizeof(buf1), i64, radix); |