[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2009-03-19 Thread Matt Wilmas
mattwil Thu Mar 19 19:27:14 2009 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH: Handle overflow when decoding large numbers and avoid 2 conversions
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.16r2=1.1.2.17diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.16 
php-src/ext/json/JSON_parser.c:1.1.2.17
--- php-src/ext/json/JSON_parser.c:1.1.2.16 Tue Mar 17 02:02:45 2009
+++ php-src/ext/json/JSON_parser.c  Thu Mar 19 19:27:14 2009
@@ -284,15 +284,27 @@
 
 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));
-   } else {
-   ZVAL_LONG(*z, l);
+   if (buf-c[0] == '-') {
+   buf-len--;
}
+
+   if (buf-len = MAX_LENGTH_OF_LONG - 1) {
+   if (buf-len == MAX_LENGTH_OF_LONG - 1) {
+   int cmp = strcmp(buf-c + (buf-c[0] == '-'), 
long_min_digits);
+
+   if (!(cmp  0 || (cmp == 0  buf-c[0] == 
'-'))) {
+   goto use_double;
+   }
+   } else {
+   goto use_double;
+   }
+   }
+
+   ZVAL_LONG(*z, strtol(buf-c, NULL, 10));
 }
 else if (type == IS_DOUBLE)
 {
+use_double:
 ZVAL_DOUBLE(*z, zend_strtod(buf-c, NULL));
 }
 else if (type == IS_STRING)



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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c /ext/json/tests bug47644.phpt

2009-03-16 Thread Scott MacVicar
scottmacTue Mar 17 02:02:45 2009 UTC

  Added files: (Branch: PHP_5_2)
/php-src/ext/json/tests bug47644.phpt 

  Modified files:  
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH Fix bug #47644 - Valid integers are truncated with json_decode()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.15r2=1.1.2.16diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.15 
php-src/ext/json/JSON_parser.c:1.1.2.16
--- php-src/ext/json/JSON_parser.c:1.1.2.15 Fri Dec 19 02:13:41 2008
+++ php-src/ext/json/JSON_parser.c  Tue Mar 17 02:02:45 2009
@@ -284,12 +284,12 @@
 
 if (type == IS_LONG)
 {
-   double d = zend_strtod(buf-c, NULL);
-   if (d  LONG_MAX || d  LONG_MIN) {
-   ZVAL_DOUBLE(*z, d);
-   } else {
-   ZVAL_LONG(*z, (long)d);
-   }
+   long l = strtol(buf-c, NULL, 10);
+   if (l  LONG_MAX || l  LONG_MIN) {
+   ZVAL_DOUBLE(*z, zend_strtod(buf-c, NULL));
+   } else {
+   ZVAL_LONG(*z, l);
+   }
 }
 else if (type == IS_DOUBLE)
 {

http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/bug47644.phpt?view=markuprev=1.1
Index: php-src/ext/json/tests/bug47644.phpt
+++ php-src/ext/json/tests/bug47644.phpt
--TEST--
Bug #47644 (valid large integers are truncated)
--SKIPIF--
?php
  if (!extension_loaded('json')) die('skip: json extension not available');
  if (PHP_INT_SIZE != 8) die(skip this test is for 64bit platform only);
?
--FILE--
?php

for ($i = 1; $i  10006; $i++) {
var_dump(json_decode([$i]));
}


echo Done\n;
?
--EXPECT--  
array(1) {
  [0]=
  int(1)
}
array(1) {
  [0]=
  int(10001)
}
array(1) {
  [0]=
  int(10002)
}
array(1) {
  [0]=
  int(10003)
}
array(1) {
  [0]=
  int(10004)
}
array(1) {
  [0]=
  int(10005)
}
Done



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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2008-12-02 Thread Matt Wilmas
mattwil Tue Dec  2 14:50:37 2008 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH: Changed logic for LONG_MIN
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.13r2=1.1.2.14diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.13 
php-src/ext/json/JSON_parser.c:1.1.2.14
--- php-src/ext/json/JSON_parser.c:1.1.2.13 Wed Jul 30 13:55:27 2008
+++ php-src/ext/json/JSON_parser.c  Tue Dec  2 14:50:37 2008
@@ -285,7 +285,7 @@
 if (type == IS_LONG)
 {
double d = zend_strtod(buf-c, NULL);
-   if (d  LONG_MAX || d  -LONG_MAX) {
+   if (d  LONG_MAX || d  LONG_MIN) {
ZVAL_DOUBLE(*z, d);
} else {
ZVAL_LONG(*z, (long)d);



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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2008-07-30 Thread Rasmus Lerdorf
rasmus  Wed Jul 30 13:55:27 2008 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  We can afford a larger stack here and other json parsers out there
  go deeper than 128.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12r2=1.1.2.13diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12 
php-src/ext/json/JSON_parser.c:1.1.2.13
--- php-src/ext/json/JSON_parser.c:1.1.2.12 Wed Jun 13 17:56:41 2007
+++ php-src/ext/json/JSON_parser.c  Wed Jul 30 13:55:27 2008
@@ -201,7 +201,7 @@
 /*29*/ {29,29,-1,-1,-1,-1,-1,-1, 
3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
 };
 
-#define JSON_PARSER_MAX_DEPTH 128
+#define JSON_PARSER_MAX_DEPTH 512
 
 
 /*



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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2007-06-13 Thread Ilia Alshanetsky
iliaa   Wed Jun 13 17:56:41 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  
  Handle very small longs via double
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.11r2=1.1.2.12diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.11 
php-src/ext/json/JSON_parser.c:1.1.2.12
--- php-src/ext/json/JSON_parser.c:1.1.2.11 Wed Jun 13 17:07:58 2007
+++ php-src/ext/json/JSON_parser.c  Wed Jun 13 17:56:41 2007
@@ -285,7 +285,7 @@
 if (type == IS_LONG)
 {
double d = zend_strtod(buf-c, NULL);
-   if (d  LONG_MAX) {
+   if (d  LONG_MAX || d  -LONG_MAX) {
ZVAL_DOUBLE(*z, d);
} else {
ZVAL_LONG(*z, (long)d);

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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2007-05-24 Thread Rasmus Lerdorf
rasmus  Thu May 24 22:37:59 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  I don't see any reason to leave the stack limitation at 20.  We have 
  reports of this limit being hit now and as far as I can tell bumping it
  to 128 isn't going break anything in the parser code.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.7r2=1.1.2.8diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.7 
php-src/ext/json/JSON_parser.c:1.1.2.8
--- php-src/ext/json/JSON_parser.c:1.1.2.7  Wed May 16 12:54:30 2007
+++ php-src/ext/json/JSON_parser.c  Thu May 24 22:37:59 2007
@@ -201,7 +201,7 @@
 /*29*/ {29,29,-1,-1,-1,-1,-1,-1, 
3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
 };
 
-#define JSON_PARSER_MAX_DEPTH 20
+#define JSON_PARSER_MAX_DEPTH 40
 
 
 /*

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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2007-05-24 Thread Rasmus Lerdorf
rasmus  Thu May 24 22:40:02 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  Make the code match the commit comment
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.8r2=1.1.2.9diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.8 
php-src/ext/json/JSON_parser.c:1.1.2.9
--- php-src/ext/json/JSON_parser.c:1.1.2.8  Thu May 24 22:37:59 2007
+++ php-src/ext/json/JSON_parser.c  Thu May 24 22:40:02 2007
@@ -201,7 +201,7 @@
 /*29*/ {29,29,-1,-1,-1,-1,-1,-1, 
3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
 };
 
-#define JSON_PARSER_MAX_DEPTH 40
+#define JSON_PARSER_MAX_DEPTH 128
 
 
 /*

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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c json.c

2007-04-13 Thread Andrei Zmievski
andrei  Fri Apr 13 21:34:12 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c json.c 
  Log:
  Fix processing of control characters; they should be escaped as \u
  sequences.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.4r2=1.1.2.5diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.4 
php-src/ext/json/JSON_parser.c:1.1.2.5
--- php-src/ext/json/JSON_parser.c:1.1.2.4  Tue Jul 25 09:06:55 2006
+++ php-src/ext/json/JSON_parser.c  Fri Apr 13 21:34:12 2007
@@ -169,7 +169,7 @@
 accepted if the end of the text is in state 9 and mode is MODE_DONE.
 */
 static const int state_transition_table[30][31] = {
-/* 0*/ { 0, 
0,-8,-1,-6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
+/* 0*/ { 0, 0,-8,-1,-6,-1,-1,-1, 
3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
 /* 1*/ { 1, 1,-1,-9,-1,-1,-1,-1, 
3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
 /* 2*/ { 2, 2,-8,-1,-6,-5,-1,-1, 
3,-1,-1,-1,20,-1,21,22,-1,-1,-1,-1,-1,13,-1,17,-1,-1,10,-1,-1,-1,-1},
 /* 3*/ { 3,-1, 3, 3, 3, 3, 3, 3,-4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3},
@@ -577,6 +577,14 @@
 case MODE_OBJECT:
 the_state = 9;
 break;
+   case MODE_DONE:
+   if (type == IS_STRING) {
+   smart_str_0(buf);
+   ZVAL_STRINGL(z, buf.c, buf.len, 
1);
+   the_state = 9;
+   break;
+   }
+   /* fall through if not IS_STRING */
 default:
 FREE_BUFFERS();
 return false;
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.13r2=1.9.2.14diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.13 php-src/ext/json/json.c:1.9.2.14
--- php-src/ext/json/json.c:1.9.2.13Thu Apr 12 19:40:38 2007
+++ php-src/ext/json/json.c Fri Apr 13 21:34:12 2007
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: json.c,v 1.9.2.13 2007/04/12 19:40:38 iliaa Exp $ */
+/* $Id: json.c,v 1.9.2.14 2007/04/13 21:34:12 andrei Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -303,7 +303,7 @@
 break;
 default:
 {
-if (us  ' ' || (us  127) == us)
+if (us = ' '  (us  127) == us)
 {
 smart_str_appendc(buf, (unsigned char) us);
 }

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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2006-07-25 Thread Antony Dovgal
tony2001Tue Jul 25 09:06:55 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  initialize variable
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.3r2=1.1.2.4diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.3 
php-src/ext/json/JSON_parser.c:1.1.2.4
--- php-src/ext/json/JSON_parser.c:1.1.2.3  Sat Jul 22 15:22:56 2006
+++ php-src/ext/json/JSON_parser.c  Tue Jul 25 09:06:55 2006
@@ -388,7 +388,7 @@
 smart_str key = {0};
 
 int type = -1;
-unsigned short utf16;
+unsigned short utf16 = 0;
 
 JSON(the_top) = -1;
 push(the_json, z, MODE_DONE);

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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c json.c

2006-07-22 Thread Nuno Lopes
nlopess Sat Jul 22 15:22:56 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c json.c 
  Log:
  more const keywording
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.2r2=1.1.2.3diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.2 
php-src/ext/json/JSON_parser.c:1.1.2.3
--- php-src/ext/json/JSON_parser.c:1.1.2.2  Thu Jul 20 09:19:02 2006
+++ php-src/ext/json/JSON_parser.c  Sat Jul 22 15:22:56 2006
@@ -139,7 +139,7 @@
 This table maps the 128 ASCII characters into the 32 character classes.
 The remaining Unicode characters should be mapped to S_ETC.
 */
-static int ascii_class[128] = {
+static const int ascii_class[128] = {
 S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
 S_ERR, S_WSP, S_WSP, S_ERR, S_ERR, S_WSP, S_ERR, S_ERR,
 S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
@@ -168,7 +168,7 @@
 0 and 29. An action is a negative number between -1 and -9. A JSON text is
 accepted if the end of the text is in state 9 and mode is MODE_DONE.
 */
-static int state_transition_table[30][31] = {
+static const int state_transition_table[30][31] = {
 /* 0*/ { 0, 
0,-8,-1,-6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
 /* 1*/ { 1, 1,-1,-9,-1,-1,-1,-1, 
3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
 /* 2*/ { 2, 2,-8,-1,-6,-5,-1,-1, 
3,-1,-1,-1,20,-1,21,22,-1,-1,-1,-1,-1,13,-1,17,-1,-1,10,-1,-1,-1,-1},
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.4r2=1.9.2.5diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.4 php-src/ext/json/json.c:1.9.2.5
--- php-src/ext/json/json.c:1.9.2.4 Thu Jul 20 09:33:28 2006
+++ php-src/ext/json/json.c Sat Jul 22 15:22:56 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: json.c,v 1.9.2.4 2006/07/20 09:33:28 tony2001 Exp $ */
+/* $Id: json.c,v 1.9.2.5 2006/07/22 15:22:56 nlopess Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -33,7 +33,7 @@
 /* If you declare any globals in php_json.h uncomment this:
 ZEND_DECLARE_MODULE_GLOBALS(json)
 */
-static char digits[] = 0123456789abcdef;
+static const char digits[] = 0123456789abcdef;
 
 /* {{{ json_functions[]
  *

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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c /ext/json/tests 001.phpt

2006-07-20 Thread Antony Dovgal
tony2001Thu Jul 20 08:24:31 2006 UTC

  Added files: (Branch: PHP_5_2)
/php-src/ext/json/tests 001.phpt 

  Modified files:  
/php-src/ext/json   JSON_parser.c 
  Log:
  fix segfault, add test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1r2=1.1.2.1diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1 
php-src/ext/json/JSON_parser.c:1.1.2.1
--- php-src/ext/json/JSON_parser.c:1.1  Tue Jan 31 08:59:06 2006
+++ php-src/ext/json/JSON_parser.c  Thu Jul 20 08:24:31 2006
@@ -338,14 +338,14 @@
 {
 if (!assoc)
 {
-add_property_zval(root, key-c, child);
+add_property_zval_ex(root, (key-len ? key-c : _empty_), 
(key-len ? (key-len + 1) : sizeof(_empty_)), child);
 #if PHP_MAJOR_VERSION = 5
 ZVAL_DELREF(child);
 #endif
 }
 else
 {
-add_assoc_zval(root, key-c, child);
+add_assoc_zval_ex(root, (key-len ? key-c : _empty_), (key-len 
? (key-len + 1) : sizeof(_empty_)), child);
 }
 key-len = 0;
 }
@@ -481,14 +481,14 @@
 
 if (!assoc)
 {
-add_property_zval(JSON(the_zstack)[JSON(the_top)], 
key.c, mval);
+add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], 
(key.len ? key.c : _empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), 
mval);
 #if PHP_MAJOR_VERSION = 5
 ZVAL_DELREF(mval);
 #endif
 }
 else
 {
-add_assoc_zval(JSON(the_zstack)[JSON(the_top)], key.c, 
mval);
+add_assoc_zval_ex(JSON(the_zstack)[JSON(the_top)], 
(key.len ? key.c : _empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), 
mval);
 }
 key.len = 0;
 buf.len = 0;
@@ -604,14 +604,14 @@
 {
 if (!assoc)
 {
-
add_property_zval(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : 
_empty_), mval);
+
add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : 
_empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), mval);
 #if PHP_MAJOR_VERSION = 5
 ZVAL_DELREF(mval);
 #endif
 }
 else
 {
-
add_assoc_zval(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : _empty_), 
mval);
+
add_assoc_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : 
_empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), mval);
 }
 key.len = 0;
 }

http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/001.phpt?view=markuprev=1.1
Index: php-src/ext/json/tests/001.phpt
+++ php-src/ext/json/tests/001.phpt
--TEST--
json_decode() tests
--FILE--
?php

var_dump(json_decode());
var_dump(json_decode());
var_dump(json_decode(, 1));
var_dump(json_decode(, 0));
var_dump(json_decode(., 1));
var_dump(json_decode(., 0));
var_dump(json_decode(?));
var_dump(json_decode(;));
var_dump(json_decode(руссиш));
var_dump(json_decode(blah));
var_dump(json_decode(NULL));
var_dump(json_decode('{ test: { foo: bar } }'));
var_dump(json_decode('{ test: { foo:  } }'));
var_dump(json_decode('{ : { foo:  } }'));
var_dump(json_decode('{ : { :  } }'));
var_dump(json_decode('{ : { :  }'));
var_dump(json_decode('{ : :  } }'));

echo Done\n;
?
--EXPECTF--
Warning: json_decode() expects at least 1 parameter, 0 given in %s on line %d
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
object(stdClass)#1 (1) {
  [test]=
  object(stdClass)#2 (1) {
[foo]=
string(3) bar
  }
}
object(stdClass)#1 (1) {
  [test]=
  object(stdClass)#2 (1) {
[foo]=
string(0) 
  }
}
object(stdClass)#1 (1) {
  [_empty_]=
  object(stdClass)#2 (1) {
[foo]=
string(0) 
  }
}
object(stdClass)#1 (1) {
  [_empty_]=
  object(stdClass)#2 (1) {
[_empty_]=
string(0) 
  }
}
NULL
NULL
Done

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



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json JSON_parser.c

2006-07-20 Thread Antony Dovgal
tony2001Thu Jul 20 09:19:02 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH: ZTS fix
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.1r2=1.1.2.2diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.1 
php-src/ext/json/JSON_parser.c:1.1.2.2
--- php-src/ext/json/JSON_parser.c:1.1.2.1  Thu Jul 20 08:24:31 2006
+++ php-src/ext/json/JSON_parser.c  Thu Jul 20 09:19:02 2006
@@ -338,7 +338,7 @@
 {
 if (!assoc)
 {
-add_property_zval_ex(root, (key-len ? key-c : _empty_), 
(key-len ? (key-len + 1) : sizeof(_empty_)), child);
+add_property_zval_ex(root, (key-len ? key-c : _empty_), 
(key-len ? (key-len + 1) : sizeof(_empty_)), child TSRMLS_CC);
 #if PHP_MAJOR_VERSION = 5
 ZVAL_DELREF(child);
 #endif
@@ -481,7 +481,7 @@
 
 if (!assoc)
 {
-add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], 
(key.len ? key.c : _empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), 
mval);
+add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], 
(key.len ? key.c : _empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), 
mval TSRMLS_CC);
 #if PHP_MAJOR_VERSION = 5
 ZVAL_DELREF(mval);
 #endif
@@ -604,7 +604,7 @@
 {
 if (!assoc)
 {
-
add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : 
_empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), mval);
+
add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : 
_empty_), (key.len ? (key.len + 1) : sizeof(_empty_)), mval TSRMLS_CC);
 #if PHP_MAJOR_VERSION = 5
 ZVAL_DELREF(mval);
 #endif

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