scottmac                Thu Feb 12 00:36:23 2009 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/json   json.c 
    /php-src/ext/json/tests     001.phpt bug42090.phpt 
  Log:
  MFH Fix bug #45989 - json_decode() doesn't return NULL on certain invalid 
strings
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.25&r2=1.9.2.26&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.25 php-src/ext/json/json.c:1.9.2.26
--- php-src/ext/json/json.c:1.9.2.25    Wed Dec 31 11:17:38 2008
+++ php-src/ext/json/json.c     Thu Feb 12 00:36:23 2009
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: json.c,v 1.9.2.25 2008/12/31 11:17:38 sebastian Exp $ */
+/* $Id: json.c,v 1.9.2.26 2009/02/12 00:36:23 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -479,13 +479,7 @@
                        RETURN_DOUBLE(d);
                }
        }
-       if (parameter_len > 1 && *parameter == '"' && 
parameter[parameter_len-1] == '"') {
-               RETURN_STRINGL(parameter+1, parameter_len-2, 1);
-       } else if (*parameter == '{' || *parameter == '[') { /* invalid JSON 
string */
                RETURN_NULL();
-       } else {
-               RETURN_STRINGL(parameter, parameter_len, 1);
-       }
     }
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/001.phpt?r1=1.1.2.6&r2=1.1.2.7&diff_format=u
Index: php-src/ext/json/tests/001.phpt
diff -u php-src/ext/json/tests/001.phpt:1.1.2.6 
php-src/ext/json/tests/001.phpt:1.1.2.7
--- php-src/ext/json/tests/001.phpt:1.1.2.6     Fri Jan 23 20:23:25 2009
+++ php-src/ext/json/tests/001.phpt     Thu Feb 12 00:36:23 2009
@@ -16,7 +16,6 @@
 var_dump(json_decode("руссиш"));
 var_dump(json_decode("blah"));
 var_dump(json_decode(NULL));
-var_dump(json_decode('[1}'));
 var_dump(json_decode('{ "test": { "foo": "bar" } }'));
 var_dump(json_decode('{ "test": { "foo": "" } }'));
 var_dump(json_decode('{ "": { "foo": "" } }'));
@@ -32,12 +31,11 @@
 NULL
 NULL
 NULL
-string(1) "."
-string(1) "."
-string(3) "<?>"
-string(1) ";"
-string(12) "руссиш"
-string(4) "blah"
+NULL
+NULL
+NULL
+NULL
+NULL
 NULL
 NULL
 object(stdClass)#%d (1) {
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/bug42090.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/json/tests/bug42090.phpt
diff -u php-src/ext/json/tests/bug42090.phpt:1.1.2.2 
php-src/ext/json/tests/bug42090.phpt:1.1.2.3
--- php-src/ext/json/tests/bug42090.phpt:1.1.2.2        Tue Jul 24 22:57:13 2007
+++ php-src/ext/json/tests/bug42090.phpt        Thu Feb 12 00:36:23 2009
@@ -1,5 +1,5 @@
 --TEST--
-Bug#42090 (json_decode causes segmentation fault)
+Bug #42090 (json_decode causes segmentation fault)
 --SKIPIF--
 <?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
@@ -16,10 +16,9 @@
 ?>
 --EXPECT--
 string(0) ""
-string(5) "".."."
-string(1) """
-string(2) """"
+NULL
+NULL
+NULL
 string(4) ""\"""
 string(1) """
 string(2) """"
-



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to