Skip to content

Commit e0743d0

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79779
2 parents 7da8c48 + 6a9d934 commit e0743d0

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

Zend/tests/bug79779.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #79779: Assertion failure when assigning property of string offset by reference
3+
--FILE--
4+
<?php
5+
$str = "";
6+
$str[1]->a = &$b;
7+
?>
8+
--EXPECTF--
9+
Fatal error: Uncaught Error: Cannot use string offset as an object in %s:%d
10+
Stack trace:
11+
#0 {main}
12+
thrown in %s on line %d

Zend/zend_execute.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,21 @@ static zend_never_inline ZEND_COLD void zend_wrong_string_offset(EXECUTE_DATA_D)
14171417
while (opline < end) {
14181418
if (opline->op1_type == IS_VAR && opline->op1.var == var) {
14191419
switch (opline->opcode) {
1420+
case ZEND_FETCH_OBJ_W:
1421+
case ZEND_FETCH_OBJ_RW:
1422+
case ZEND_FETCH_OBJ_FUNC_ARG:
1423+
case ZEND_FETCH_OBJ_UNSET:
1424+
case ZEND_ASSIGN_OBJ:
14201425
case ZEND_ASSIGN_OBJ_OP:
1426+
case ZEND_ASSIGN_OBJ_REF:
14211427
msg = "Cannot use string offset as an object";
14221428
break;
1429+
case ZEND_FETCH_DIM_W:
1430+
case ZEND_FETCH_DIM_RW:
1431+
case ZEND_FETCH_DIM_FUNC_ARG:
1432+
case ZEND_FETCH_DIM_UNSET:
1433+
case ZEND_FETCH_LIST_W:
1434+
case ZEND_ASSIGN_DIM:
14231435
case ZEND_ASSIGN_DIM_OP:
14241436
msg = "Cannot use string offset as an array";
14251437
break;
@@ -1437,21 +1449,6 @@ static zend_never_inline ZEND_COLD void zend_wrong_string_offset(EXECUTE_DATA_D)
14371449
case ZEND_POST_DEC:
14381450
msg = "Cannot increment/decrement string offsets";
14391451
break;
1440-
case ZEND_FETCH_DIM_W:
1441-
case ZEND_FETCH_DIM_RW:
1442-
case ZEND_FETCH_DIM_FUNC_ARG:
1443-
case ZEND_FETCH_DIM_UNSET:
1444-
case ZEND_FETCH_LIST_W:
1445-
case ZEND_ASSIGN_DIM:
1446-
msg = "Cannot use string offset as an array";
1447-
break;
1448-
case ZEND_FETCH_OBJ_W:
1449-
case ZEND_FETCH_OBJ_RW:
1450-
case ZEND_FETCH_OBJ_FUNC_ARG:
1451-
case ZEND_FETCH_OBJ_UNSET:
1452-
case ZEND_ASSIGN_OBJ:
1453-
msg = "Cannot use string offset as an object";
1454-
break;
14551452
case ZEND_ASSIGN_REF:
14561453
case ZEND_ADD_ARRAY_ELEMENT:
14571454
case ZEND_INIT_ARRAY:

0 commit comments

Comments
 (0)