Skip to content

Commit 2b6d19e

Browse files
committed
Fix for empty space in list(), update tests
1 parent 7ba2254 commit 2b6d19e

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

Zend/tests/list_references_array.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ array(2) {
6565
[1]=>
6666
int(2)
6767
}
68+
69+
Notice: Undefined offset: 2 in %s on line %d
6870
array(3) {
6971
[0]=>
7072
int(2)
@@ -87,6 +89,8 @@ array(2) {
8789
["one"]=>
8890
&int(2)
8991
}
92+
93+
Notice: Undefined index: three in %s on line %d
9094
array(3) {
9195
["two"]=>
9296
int(2)
@@ -130,6 +134,10 @@ array(2) {
130134
int(2)
131135
}
132136
NULL
137+
138+
Notice: Undefined offset: 2 in %s on line %d
139+
140+
Notice: Undefined offset: 0 in %s on line %d
133141
array(3) {
134142
[0]=>
135143
int(1)
@@ -156,6 +164,8 @@ array(3) {
156164
}
157165
}
158166
NULL
167+
168+
Notice: Undefined offset: 1 in %s on line %d
159169
array(3) {
160170
[0]=>
161171
int(1)

Zend/tests/list_references_object.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ object(StorageRef)#1 (1) {
137137
NULL
138138
}
139139
}
140+
141+
Notice: Undefined offset: 0 in %s on line %d
140142
object(StorageRef)#2 (1) {
141143
["s":"StorageRef":private]=>
142144
array(3) {
@@ -166,6 +168,8 @@ object(StorageNoRef)#1 (1) {
166168
Notice: Undefined offset: 2 in %s on line %d
167169

168170
Notice: Indirect modification of overloaded element of StorageNoRef has no effect in %s on line %d
171+
172+
Notice: Undefined offset: 0 in %s on line %d
169173
object(StorageNoRef)#2 (1) {
170174
["s":"StorageNoRef":private]=>
171175
array(2) {

Zend/zend_compile.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,16 +2821,18 @@ static zend_bool zend_set_list_assign_reference(zend_ast *ast) { /* {{{ */
28212821

28222822
for (i = 0; i < list->children; ++i) {
28232823
zend_ast *elem_ast = list->child[i];
2824-
zend_ast *var_ast = elem_ast->child[0];
2824+
if (elem_ast) {
2825+
zend_ast *var_ast = elem_ast->child[0];
28252826

2826-
if (elem_ast->kind == ZEND_AST_ARRAY_ELEM && elem_ast->attr) {
2827-
has_reference = 1;
2828-
} else if (elem_ast->kind == ZEND_AST_ARRAY_ELEM && var_ast->kind == ZEND_AST_ARRAY) {
2829-
has_reference = zend_set_list_assign_reference(var_ast);
2830-
}
2827+
if (elem_ast->kind == ZEND_AST_ARRAY_ELEM && elem_ast->attr) {
2828+
has_reference = 1;
2829+
} else if (elem_ast->kind == ZEND_AST_ARRAY_ELEM && var_ast->kind == ZEND_AST_ARRAY) {
2830+
has_reference = zend_set_list_assign_reference(var_ast);
2831+
}
28312832

2832-
if (has_reference) {
2833-
break;
2833+
if (has_reference) {
2834+
break;
2835+
}
28342836
}
28352837
}
28362838

0 commit comments

Comments
 (0)