diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2024-02-03 15:48:57 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-02 18:12:23 +0100 |
commit | 58440e5b3714bf37c19a37c24029d398e573ed19 (patch) | |
tree | dba34dc4cd186b497a323a1935a9388fa0a4a21b /lib/quickjs | |
parent | 600cee2b429c3e9a206de8c963aeddb5f9210823 (diff) | |
download | chawan-58440e5b3714bf37c19a37c24029d398e573ed19.tar.gz |
avoid using INT64_MAX in double comparisons because it cannot be exactly represented as a double (bnoordhuis)
Diffstat (limited to 'lib/quickjs')
-rw-r--r-- | lib/quickjs/quickjs.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c index 2348108d..e18ba484 100644 --- a/lib/quickjs/quickjs.c +++ b/lib/quickjs/quickjs.c @@ -10873,7 +10873,7 @@ static int JS_ToInt64SatFree(JSContext *ctx, int64_t *pres, JSValue val) } else { if (d < INT64_MIN) *pres = INT64_MIN; - else if (d > INT64_MAX) + else if (d >= 0x1p63) /* must use INT64_MAX + 1 because INT64_MAX cannot be exactly represented as a double */ *pres = INT64_MAX; else *pres = (int64_t)d; @@ -55458,7 +55458,8 @@ static JSValue js_atomics_wait(JSContext *ctx, } if (JS_ToFloat64(ctx, &d, argv[3])) return JS_EXCEPTION; - if (isnan(d) || d > INT64_MAX) + /* must use INT64_MAX + 1 because INT64_MAX cannot be exactly represented as a double */ + if (isnan(d) || d >= 0x1p63) timeout = INT64_MAX; else if (d < 0) timeout = 0; |