Skip to content

Commit e53d622

Browse files
committed
Fix UB in js_dtoa1
1 parent fd6e039 commit e53d622

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

quickjs.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -11492,8 +11492,10 @@ static void js_dtoa1(char *buf, double d, int radix, int n_digits, int flags)
1149211492
} else if (flags == JS_DTOA_VAR_FORMAT) {
1149311493
int64_t i64;
1149411494
char buf1[70], *ptr;
11495+
if (d > (double)MAX_SAFE_INTEGER || d < (double)-MAX_SAFE_INTEGER)
11496+
goto generic_conv;
1149511497
i64 = (int64_t)d;
11496-
if (d != i64 || i64 > MAX_SAFE_INTEGER || i64 < -MAX_SAFE_INTEGER)
11498+
if (d != i64)
1149711499
goto generic_conv;
1149811500
/* fast path for integers */
1149911501
ptr = i64toa(buf1 + sizeof(buf1), i64, radix);

0 commit comments

Comments
 (0)