Skip to content

Commit 2df4432

Browse files
committed
Fixed bug #36071 (Engine Crash related with 'clone')
1 parent 6115e49 commit 2df4432

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PHP NEWS
44
- Fixed an error in mysqli_fetch_fields (returned NULL instead of an
55
array when row number > field_count). (Georg)
66
- Renamed CachingRecursiveIterator to RecursiveCachingIterator. (Marcus)
7+
- Fixed bug #36071 (Engine Crash related with 'clone'). (Dmitry)
78
- Fixed bug #36006 (Problem with $this in __destruct()). (Dmitry)
89
- Fixed bug #35612 (iis6 Access Violation crash). (Dmitry, alacn.uhahaa)
910
- Fixed bug #35570 (segfault when re-using soap client object). (Dmitry)

Zend/tests/bug36071.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #36071 (Engine Crash related with 'clone')
3+
--INI--
4+
error_reporting=4095
5+
--FILE--
6+
<?php
7+
$a = clone 0;
8+
$a[0]->b = 0;
9+
echo "ok\n";
10+
?>
11+
--EXPECTF--
12+
Warning: __clone method called on non-object in %sbug36071.php on line 2
13+
ok

Zend/zend_execute.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,14 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode
371371
zval *value = get_zval_ptr(value_op, Ts, &free_value, BP_VAR_R);
372372
zval **retval = &T(result->u.var).var.ptr;
373373

374+
if (*object_ptr == EG(error_zval_ptr)) {
375+
FREE_OP(Ts, op2, EG(free_op2));
376+
*retval = EG(uninitialized_zval_ptr);
377+
SELECTIVE_PZVAL_LOCK(*retval, result);
378+
FREE_OP(Ts, value_op, free_value);
379+
return;
380+
}
381+
374382
make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */
375383
object = *object_ptr;
376384

0 commit comments

Comments
 (0)