]> granicus.if.org Git - php/commitdiff
Fixed bug #42818 ($foo = clone(array()); leaks memory)
authorDmitry Stogov <dmitry@php.net>
Wed, 3 Oct 2007 09:47:25 +0000 (09:47 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 3 Oct 2007 09:47:25 +0000 (09:47 +0000)
NEWS
Zend/tests/bug42818.phpt [new file with mode: 0644]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/NEWS b/NEWS
index f926254be25f38f93fdbf57ee57943ad0109b610..0488d74c4c5594f91e08907bda4b68493cb4d84e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,7 @@ PHP                                                                        NEWS
 - Fixed htmlentities/htmlspecialchars not to accept partial multibyte
   sequences. (Stas)
 
+- Fixed bug #42818 ($foo = clone(array()); leaks memory). (Dmitry)
 - Fixed bug #42785 (json_encode() formats doubles according to locale rather  
   then following standard syntax). (Ilia)
 - Fixed bug #42772 (Storing $this in a static var fails while handling a cast
diff --git a/Zend/tests/bug42818.phpt b/Zend/tests/bug42818.phpt
new file mode 100644 (file)
index 0000000..a1d79a4
--- /dev/null
@@ -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
+
index 6405b094369ac3beaffbd31b480efd562c159791..39235dba7b49fc8ad394891d11e68fcdd907c9bb 100644 (file)
@@ -2534,7 +2534,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();
        }
 
index 3ec65b0e3cf5755efba848034cbed6295fe77049..2caa1db50e6fb23053f7dc0cfc2843576de59a11 100644 (file)
@@ -4415,7 +4415,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();
        }