diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2023-12-22 11:02:39 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-22 15:05:54 +0100 |
commit | 4ca3946a7fdbfc7e8474e97f93ac75e22db60a8d (patch) | |
tree | 34316c4d2ed2ffbaf4d4d1af6b0db426efc0c85e /lib/quickjs/quickjs.c | |
parent | ea53099fac6d5b1e3b477c239fced40383a01721 (diff) | |
download | chawan-4ca3946a7fdbfc7e8474e97f93ac75e22db60a8d.tar.gz |
fixed js_strtod with large integers (github issue #206)
Diffstat (limited to 'lib/quickjs/quickjs.c')
-rw-r--r-- | lib/quickjs/quickjs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c index 59b8e9f3..80f4946a 100644 --- a/lib/quickjs/quickjs.c +++ b/lib/quickjs/quickjs.c @@ -10079,12 +10079,13 @@ static inline int to_digit(int c) } /* XXX: remove */ -static double js_strtod(const char *p, int radix, BOOL is_float) +static double js_strtod(const char *str, int radix, BOOL is_float) { double d; int c; if (!is_float || radix != 10) { + const char *p = str; uint64_t n_max, n; int int_exp, is_neg; @@ -10111,6 +10112,8 @@ static double js_strtod(const char *p, int radix, BOOL is_float) if (n <= n_max) { n = n * radix + c; } else { + if (radix == 10) + goto strtod_case; int_exp++; } p++; @@ -10122,7 +10125,8 @@ static double js_strtod(const char *p, int radix, BOOL is_float) if (is_neg) d = -d; } else { - d = strtod(p, NULL); + strtod_case: + d = strtod(str, NULL); } return d; } |