Skip to content

Commit 16d59aa

Browse files
committed
Fixed bug #65969 (Chain assignment with T_LIST failure)
1 parent 63f3ff7 commit 16d59aa

File tree

5 files changed

+164
-128
lines changed

5 files changed

+164
-128
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PHP NEWS
77
- Core:
88
. Fixed bug #66094 (unregister_tick_function tries to cast a Closure to a
99
string). (Laruence)
10+
. Fixed bug #65969 (Chain assignment with T_LIST failure). (Dmitry)
1011
. Fixed bug #65947 (basename is no more working after fgetcsv in certain
1112
situation). (Laruence)
1213

Zend/tests/bug65969.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #65969 (Chain assignment with T_LIST failure)
3+
--FILE--
4+
<?php
5+
$obj = new stdClass;
6+
list($a,$b) = $obj->prop = [1,2];
7+
var_dump($a,$b);
8+
--EXPECT--
9+
int(1)
10+
int(2)

Zend/zend_execute.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,9 +1248,8 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container
12481248
}
12491249
}
12501250

1251-
static void zend_fetch_dimension_address_read(temp_variable *result, zval **container_ptr, zval *dim, int dim_type, int type TSRMLS_DC)
1251+
static void zend_fetch_dimension_address_read(temp_variable *result, zval *container, zval *dim, int dim_type, int type TSRMLS_DC)
12521252
{
1253-
zval *container = *container_ptr;
12541253
zval **retval;
12551254

12561255
switch (Z_TYPE_P(container)) {

Zend/zend_vm_def.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,19 +1166,17 @@ ZEND_VM_HANDLER(81, ZEND_FETCH_DIM_R, VAR|CV, CONST|TMP|VAR|CV)
11661166
{
11671167
USE_OPLINE
11681168
zend_free_op free_op1, free_op2;
1169-
zval **container;
1169+
zval *container;
11701170

11711171
SAVE_OPLINE();
11721172

1173-
if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) &&
1174-
OP1_TYPE != IS_CV &&
1175-
EX_T(opline->op1.var).var.ptr_ptr) {
1176-
PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr);
1173+
if (OP1_TYPE == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) {
1174+
PZVAL_LOCK(EX_T(opline->op1.var).var.ptr);
11771175
}
1178-
container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R);
1176+
container = GET_OP1_ZVAL_PTR(BP_VAR_R);
11791177
zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R TSRMLS_CC);
11801178
FREE_OP2();
1181-
FREE_OP1_VAR_PTR();
1179+
FREE_OP1();
11821180
CHECK_EXCEPTION();
11831181
ZEND_VM_NEXT_OPCODE();
11841182
}
@@ -1243,13 +1241,13 @@ ZEND_VM_HANDLER(90, ZEND_FETCH_DIM_IS, VAR|CV, CONST|TMP|VAR|CV)
12431241
{
12441242
USE_OPLINE
12451243
zend_free_op free_op1, free_op2;
1246-
zval **container;
1244+
zval *container;
12471245

12481246
SAVE_OPLINE();
1249-
container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_IS);
1247+
container = GET_OP1_ZVAL_PTR(BP_VAR_IS);
12501248
zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_IS TSRMLS_CC);
12511249
FREE_OP2();
1252-
FREE_OP1_VAR_PTR();
1250+
FREE_OP1();
12531251
CHECK_EXCEPTION();
12541252
ZEND_VM_NEXT_OPCODE();
12551253
}
@@ -1258,28 +1256,32 @@ ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
12581256
{
12591257
USE_OPLINE
12601258
zend_free_op free_op1, free_op2;
1261-
zval **container;
12621259

12631260
SAVE_OPLINE();
12641261

12651262
if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) {
1266-
container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
1263+
zval **container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
1264+
12671265
if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
12681266
zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
12691267
}
12701268
zend_fetch_dimension_address(&EX_T(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_W TSRMLS_CC);
12711269
if (OP1_TYPE == IS_VAR && OP1_FREE && READY_TO_DESTROY(free_op1.var)) {
12721270
EXTRACT_ZVAL_PTR(&EX_T(opline->result.var));
12731271
}
1272+
FREE_OP2();
1273+
FREE_OP1_VAR_PTR();
12741274
} else {
1275+
zval *container;
1276+
12751277
if (OP2_TYPE == IS_UNUSED) {
12761278
zend_error_noreturn(E_ERROR, "Cannot use [] for reading");
12771279
}
1278-
container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R);
1280+
container = GET_OP1_ZVAL_PTR(BP_VAR_R);
12791281
zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R TSRMLS_CC);
1282+
FREE_OP2();
1283+
FREE_OP1();
12801284
}
1281-
FREE_OP2();
1282-
FREE_OP1_VAR_PTR();
12831285
CHECK_EXCEPTION();
12841286
ZEND_VM_NEXT_OPCODE();
12851287
}

0 commit comments

Comments
 (0)