about summary refs log tree commit diff stats
path: root/lib/quickjs/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2023-12-22 11:02:39 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-22 15:05:54 +0100
commit4ca3946a7fdbfc7e8474e97f93ac75e22db60a8d (patch)
tree34316c4d2ed2ffbaf4d4d1af6b0db426efc0c85e /lib/quickjs/quickjs.c
parentea53099fac6d5b1e3b477c239fced40383a01721 (diff)
downloadchawan-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.c8
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;
 }