Browse Source

- MFH: Fixed bug #46215 (json_encode mutates its parameter and has some class-specific state)

PHP-5.2.1RC1
Felipe Pena 18 years ago
parent
commit
df9dc12b1e
  1. 6
      NEWS
  2. 3
      ext/json/json.c
  3. 23
      ext/json/tests/bug46215.phpt

6
NEWS

@ -18,10 +18,12 @@ PHP NEWS
(Scott)
- Fixed a crash on invalid method in ReflectionParameter constructor.
(Christian Seiler)
- Fixed bug #46215 (json_encode mutates its parameter and has some
class-specific state). (Felipe)
- Fixed bug #46191 (BC break: DOMDocument saveXML() doesn't accept null). (Rob)
- Fixed bug #46157 (PDOStatement::fetchObject prototype error). (Felipe)
- Fixed bug #46147 (after stream seek, appending stream filter reads incorrect data).
(Greg)
- Fixed bug #46147 (after stream seek, appending stream filter reads
incorrect data). (Greg)
- Fixed bug #46088 (RegexIterator::accept - segfault). (Felipe)
- Fixed bug #46059 (Compile failure under IRIX 6.5.30 building posix.c).
(Arnaud)

3
ext/json/json.c

@ -181,6 +181,9 @@ static void json_encode_array(smart_str *buf, zval **val TSRMLS_DC) { /* {{{ */
if (i == HASH_KEY_IS_STRING) {
if (key[0] == '\0' && Z_TYPE_PP(val) == IS_OBJECT) {
/* Skip protected and private members. */
if (tmp_ht) {
tmp_ht->nApplyCount--;
}
continue;
}

23
ext/json/tests/bug46215.phpt

@ -0,0 +1,23 @@
--TEST--
Bug #46215 (json_encode mutates its parameter and has some class-specific state)
--FILE--
<?php
class foo {
protected $a = array();
}
$a = new foo;
$x = json_encode($a);
print_r($a);
?>
--EXPECT--
foo Object
(
[a:protected] => Array
(
)
)
Loading…
Cancel
Save