]> granicus.if.org Git - php/commitdiff
Deal with overflow when decoding large numbers
authorScott MacVicar <scottmac@php.net>
Tue, 17 Mar 2009 14:56:49 +0000 (14:56 +0000)
committerScott MacVicar <scottmac@php.net>
Tue, 17 Mar 2009 14:56:49 +0000 (14:56 +0000)
ext/json/JSON_parser.c

index ec874a7ec235d9ade422c35ffcab7c198509a2b0..f00b5d4c0111cde7e7aeb56ed0f2376aea45fc3e 100644 (file)
@@ -290,8 +290,9 @@ static void json_create_zval(zval **z, smart_str *buf, int type TSRMLS_DC)
     if (type == IS_LONG)
     {
                long l = strtol(buf->c, NULL, 10);
-               if (l > LONG_MAX || l < LONG_MIN) {
-                       ZVAL_DOUBLE(*z, zend_strtod(buf->c, NULL));
+               double d = zend_strtod(buf->c, NULL);
+               if (d > LONG_MAX || d < LONG_MIN) {
+                       ZVAL_DOUBLE(*z, d);
                } else {
                        ZVAL_LONG(*z, l);
                }