Skip to content

Commit 3332943

Browse files
committed
Fixed Bug #62005 (unexpected behavior when incrementally assigning to a member of a null object)
1 parent 950d5ee commit 3332943

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ PHP NEWS
1111
(Laruence)
1212

1313
- Core:
14+
. Fixed bug #62005 (unexpected behavior when incrementally assigning to a
15+
member of a null object). (Laruence)
1416
. Fixed bug #61730 (Segfault from array_walk modifying an array passed by
1517
reference). (Laruence)
1618
. Fixed missing bound check in iptcparse(). (chris at chiappa.net)

Zend/tests/bug62005.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #62005 (unexpected behavior when incrementally assigning to a member of a null object)
3+
--FILE--
4+
<?php
5+
function add_points($player, $points) {
6+
$player->energy += $points;
7+
print_r($player);
8+
}
9+
add_points(NULL, 2);
10+
--EXPECTF--
11+
Strict Standards: Creating default object from empty value in %sbug62005.php on line %d
12+
stdClass Object
13+
(
14+
[energy] => 2
15+
)

Zend/zend_execute.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,10 @@ static inline void make_real_object(zval **object_ptr TSRMLS_DC)
432432
|| (Z_TYPE_PP(object_ptr) == IS_BOOL && Z_LVAL_PP(object_ptr) == 0)
433433
|| (Z_TYPE_PP(object_ptr) == IS_STRING && Z_STRLEN_PP(object_ptr) == 0)
434434
) {
435-
zend_error(E_STRICT, "Creating default object from empty value");
436-
437435
SEPARATE_ZVAL_IF_NOT_REF(object_ptr);
438436
zval_dtor(*object_ptr);
439437
object_init(*object_ptr);
438+
zend_error(E_STRICT, "Creating default object from empty value");
440439
}
441440
}
442441

0 commit comments

Comments
 (0)