1
0
mirror of https://github.com/php/php-src.git synced 2026-04-03 14:12:38 +02:00

Fixed bug #42818 ($foo = clone(array()); leaks memory)

This commit is contained in:
Dmitry Stogov
2007-10-03 09:47:45 +00:00
parent 1491992f76
commit 68055015eb
3 changed files with 11 additions and 2 deletions

9
Zend/tests/bug42818.phpt Normal file
View File

@@ -0,0 +1,9 @@
--TEST--
Bug #42818 ($foo = clone(array()); leaks memory)
--FILE--
<?php
$foo = clone(array());
?>
--EXPECTF--
Warning: __clone method called on non-object in %sbug42818.php on line 2

View File

@@ -2582,7 +2582,7 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
zend_error(E_WARNING, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
FREE_OP1_IF_VAR();
FREE_OP1();
ZEND_VM_NEXT_OPCODE();
}

View File

@@ -4669,7 +4669,7 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_error(E_WARNING, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
zval_dtor(free_op1.var);
ZEND_VM_NEXT_OPCODE();
}