cvs: ZendEngine2(PHP_5_2) / zend_API.c /tests clone_uncloneable.phpt

[email protected] ("Antony Dovgal")
Newsgroups php.zend-engine.cvs
Message-ID <cvstony20011204824527@cvsserver>
tony2001		Thu Mar  6 17:28:47 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /ZendEngine2/tests	clone_uncloneable.phpt 

  Modified files:              
    /ZendEngine2	zend_API.c 
  Log:
  MFH: fix segfault when trying to clone uncloneable object 
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.37&r2=1.296.2.27.2.38&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.37 ZendEngine2/zend_API.c:1.296.2.27.2.38
--- ZendEngine2/zend_API.c:1.296.2.27.2.37	Tue Feb 19 06:52:58 2008
+++ ZendEngine2/zend_API.c	Thu Mar  6 17:28:47 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c,v 1.296.2.27.2.37 2008/02/19 06:52:58 sebastian Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.38 2008/03/06 17:28:47 tony2001 Exp $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -168,9 +168,15 @@
 			*value_ptr = **value;
 			INIT_PZVAL(value_ptr);
 			zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
+
+			if (Z_OBJ_HANDLER_PP(value, clone_obj) == NULL) {
+				zend_error(E_CORE_ERROR, "Trying to clone uncloneable object of class %s", class_name);
+			}
+
 			if(!dup) {
 				efree(class_name);
 			}
+
 			value_ptr->value.obj = Z_OBJ_HANDLER_PP(value, clone_obj)(*value TSRMLS_CC);
 			zval_ptr_dtor(value);
 			*value = value_ptr;

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/clone_uncloneable.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/clone_uncloneable.phpt
+++ ZendEngine2/tests/clone_uncloneable.phpt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.