summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-03-06 17:28:47 +0000
committerAntony Dovgal <tony2001@php.net>2008-03-06 17:28:47 +0000
commitba9ad966c3895f2d7af2ec28a18d0034db1554eb (patch)
treea41464c3748fa99e8a3f932f33c1349901b6f7eb
parent1af0116cf09e25805b6a5dc383bd345e6e55e66e (diff)
downloadphp-git-ba9ad966c3895f2d7af2ec28a18d0034db1554eb.tar.gz
MFH: fix segfault when trying to clone uncloneable object
-rw-r--r--Zend/tests/clone_uncloneable.phpt20
-rw-r--r--Zend/zend_API.c6
2 files changed, 26 insertions, 0 deletions
diff --git a/Zend/tests/clone_uncloneable.phpt b/Zend/tests/clone_uncloneable.phpt
new file mode 100644
index 0000000000..c991d10600
--- /dev/null
+++ b/Zend/tests/clone_uncloneable.phpt
@@ -0,0 +1,20 @@
+--TEST--
+cloning uncloneable object
+--SKIPIF--
+<?php if (!extension_loaded("xsl")) die("skip xsl extension is missing");?>
+--INI--
+zend.ze1_compatibility_mode=1
+--FILE--
+<?php
+
+$new = &new XSLTProcessor();
+var_dump($new);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Strict Standards: Assigning the return value of new by reference is deprecated in %s on line %d
+
+Strict Standards: Implicit cloning object of class 'XSLTProcessor' because of 'zend.ze1_compatibility_mode' in %s on line %d
+
+Fatal error: Trying to clone uncloneable object of class XSLTProcessor in Unknown on line 0
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 5a4697175c..2be99be254 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -168,9 +168,15 @@ ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_arr
*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;