Skip to content

Commit

Permalink
Fix use of UNDEF instead of NULL in read_dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Mar 20, 2016
1 parent 9564998 commit 1f6d27d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
43 changes: 43 additions & 0 deletions Zend/tests/ArrayAccess_indirect_append.phpt
@@ -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)
}
}
}
}
2 changes: 0 additions & 2 deletions Zend/tests/bug69955.phpt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_object_handlers.c
Expand Up @@ -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);
Expand Down

0 comments on commit 1f6d27d

Please sign in to comment.