]> granicus.if.org Git - php/commitdiff
Fix use of UNDEF instead of NULL in read_dimension
authorNikita Popov <nikic@php.net>
Sun, 20 Mar 2016 11:58:58 +0000 (12:58 +0100)
committerNikita Popov <nikic@php.net>
Sun, 20 Mar 2016 12:33:17 +0000 (13:33 +0100)
Zend/tests/ArrayAccess_indirect_append.phpt [new file with mode: 0644]
Zend/tests/bug69955.phpt
Zend/zend_object_handlers.c

diff --git a/Zend/tests/ArrayAccess_indirect_append.phpt b/Zend/tests/ArrayAccess_indirect_append.phpt
new file mode 100644 (file)
index 0000000..6f3da7c
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+Using indirect append on ArrayAccess object
+--FILE--
+<?php
+
+class AA implements ArrayAccess {
+    private $data = [];
+    public function &offsetGet($name) {
+        if (null === $name) {
+            return $this->data[];
+        } else {
+            return $this->data[$name];
+        }
+    }
+    public function offsetSet($name, $value) {
+        $this->data[$name] = $value;
+    }
+    public function offsetUnset($name) {}
+    public function offsetExists($name) {}
+}
+
+$aa = new AA;
+$aa[3] = 1;
+$aa[][][0] = 2;
+var_dump($aa);
+
+?>
+--EXPECT--
+object(AA)#1 (1) {
+  ["data":"AA":private]=>
+  array(2) {
+    [3]=>
+    int(1)
+    [4]=>
+    array(1) {
+      [0]=>
+      array(1) {
+        [0]=>
+        int(2)
+      }
+    }
+  }
+}
index b6d74242ee4dafc8fb8da48723b6795245f22d43..33c36850c06bedbca3941c47a5b5252b4a157498 100644 (file)
@@ -27,8 +27,6 @@ $c10 = new C10;
 var_dump($c10[] += 5);
 --EXPECTF--
 Inside C10::offsetGet
-
-Notice: Undefined variable: offset in %sbug69955.php on line 10
 NULL
 
 Inside C10::offsetSet
index c66f8ad7c3f5718f4d5623a79ce217657fc2e1ef..091a0a0d5382b9aa471070d323ab781263dfada9 100644 (file)
@@ -712,7 +712,7 @@ zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv) /*
        if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) {
                if(offset == NULL) {
                        /* [] construct */
-                       ZVAL_UNDEF(&tmp);
+                       ZVAL_NULL(&tmp);
                        offset = &tmp;
                } else {
                        SEPARATE_ARG_IF_REF(offset);