]> granicus.if.org Git - php/commitdiff
Don't recurse into USE_OTHER checking STD_PROP_LIST
authorNikita Popov <nikic@php.net>
Mon, 22 Feb 2016 12:04:19 +0000 (13:04 +0100)
committerNikita Popov <nikic@php.net>
Mon, 22 Feb 2016 12:04:19 +0000 (13:04 +0100)
If STD_PROP_LIST is explicitly disabled in the constructor, it
should really be disabled.

ext/spl/spl_array.c
ext/spl/tests/ArrayObject_std_props_no_recursion.phpt [new file with mode: 0644]

index df2c7d126a8bd49423d4bf635c3bde25eab4c0b4..333830ad9ded9479461a41c26f804556dd3b63ef 100644 (file)
@@ -92,7 +92,7 @@ static inline HashTable *spl_array_get_hash_table(spl_array_object* intern, int
                return intern->std.properties;
        } else if (intern->ar_flags & SPL_ARRAY_USE_OTHER) {
                spl_array_object *other = Z_SPLARRAY_P(&intern->array);
-               return spl_array_get_hash_table(other, check_std_props);
+               return spl_array_get_hash_table(other, 0);
        } else {
                return HASH_OF(&intern->array);
        }
diff --git a/ext/spl/tests/ArrayObject_std_props_no_recursion.phpt b/ext/spl/tests/ArrayObject_std_props_no_recursion.phpt
new file mode 100644 (file)
index 0000000..193e972
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+Don't recurse into USE_OTHER when checking for STD_PROP_LIST
+--FILE--
+<?php
+
+$a = new ArrayObject([1, 2, 3], ArrayObject::STD_PROP_LIST);
+$a->prop = 'a';
+$b = new ArrayObject($a, 0);
+$b->prop = 'b';
+var_dump((array) $b);
+$c = new ArrayObject($a);
+$c->prop = 'c';
+var_dump((array) $c);
+
+?>
+--EXPECT--
+array(3) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+}
+array(1) {
+  ["prop"]=>
+  string(1) "c"
+}