cvs: ZendEngine2(PHP_5_2) / zend_object_handlers.c zend_objects.c /tests bug38220.phpt php-src NEWS
| From: | Dmitry Stogov | Date: | Wed, 26 Jul 2006 15:29:27 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_2) / zend_object_handlers.c zend_objects.c /tests bug38220.phpt php-src NEWS | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5134@lists.php.net to get a copy of this message | ||
dmitry Wed Jul 26 15:29:27 2006 UTC
Added files: (Branch: PHP_5_2)
/ZendEngine2/tests bug38220.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_object_handlers.c zend_objects.c
Log:
Fixed bug #38220 (Crash on some object operations)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.150&r2=1.2027.2.547.2.151&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.150 php-src/NEWS:1.2027.2.547.2.151
--- php-src/NEWS:1.2027.2.547.2.150 Wed Jul 26 12:07:13 2006
+++ php-src/NEWS Wed Jul 26 15:29:27 2006
@@ -9,6 +9,7 @@
. ext/filepro (Derick, Tony)
. ext/hwapi (Derick, Tony)
+- Fixed bug #38220 (Crash on some object operations). (Dmitry)
- Fixed bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too
much memory). (Tony)
- Fixed bug #38214 (gif interlace output cannot work). (Pierre)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.135.2.6.2.10&r2=1.135.2.6.2.11&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.10
ZendEngine2/zend_object_handlers.c:1.135.2.6.2.11
--- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.10 Mon Jul 24 17:58:32 2006
+++ ZendEngine2/zend_object_handlers.c Wed Jul 26 15:29:27 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.135.2.6.2.10 2006/07/24 17:58:32 helly Exp $ */
+/* $Id: zend_object_handlers.c,v 1.135.2.6.2.11 2006/07/26 15:29:27 dmitry Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -373,7 +373,6 @@
zend_object *zobj;
zval *tmp_member = NULL;
zval **variable_ptr;
- int setter_done = 0;
zend_property_info *property_info;
zobj = Z_OBJ_P(object);
@@ -390,10 +389,8 @@
property_info = zend_get_property_info(zobj->ce, member, (zobj->ce->__set != NULL)
TSRMLS_CC);
if (property_info && zend_hash_quick_find(zobj->properties, property_info->name,
property_info->name_length+1, property_info->h, (void **) &variable_ptr) == SUCCESS) {
- if (*variable_ptr == value) {
- /* if we already have this value there, we don't actually need to do anything */
- setter_done = 1;
- } else {
+ /* if we already have this value there, we don't actually need to do anything */
+ if (*variable_ptr != value) {
/* if we are assigning reference, we shouldn't move it, but instead assign variable
to the same pointer */
if (PZVAL_IS_REF(*variable_ptr)) {
@@ -406,10 +403,20 @@
zval_copy_ctor(*variable_ptr);
}
zval_dtor(&garbage);
- setter_done = 1;
+ } else {
+ zval *garbage = *variable_ptr;
+
+ /* if we assign referenced variable, we should separate it */
+ value->refcount++;
+ if (PZVAL_IS_REF(value)) {
+ SEPARATE_ZVAL(&value);
+ }
+ *variable_ptr = value;
+ zval_ptr_dtor(&garbage);
}
}
} else {
+ int setter_done = 0;
zend_guard *guard;
if (zobj->ce->__set &&
@@ -422,18 +429,18 @@
setter_done = 1;
guard->in_set = 0;
}
- }
-
- if (!setter_done) {
- zval **foo;
+ if (!setter_done) {
+ zval **foo;
- /* if we assign referenced variable, we should separate it */
- value->refcount++;
- if (PZVAL_IS_REF(value)) {
- SEPARATE_ZVAL(&value);
+ /* if we assign referenced variable, we should separate it */
+ value->refcount++;
+ if (PZVAL_IS_REF(value)) {
+ SEPARATE_ZVAL(&value);
+ }
+ zend_hash_quick_update(zobj->properties, property_info->name,
property_info->name_length+1, property_info->h, &value, sizeof(zval *), (void **)
&foo);
}
- zend_hash_quick_update(zobj->properties, property_info->name,
property_info->name_length+1, property_info->h, &value, sizeof(zval *), (void **)
&foo);
}
+
if (tmp_member) {
zval_ptr_dtor(&tmp_member);
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_objects.c?r1=1.56.2.3.2.4&r2=1.56.2.3.2.5&diff_format=u
Index: ZendEngine2/zend_objects.c
diff -u ZendEngine2/zend_objects.c:1.56.2.3.2.4 ZendEngine2/zend_objects.c:1.56.2.3.2.5
--- ZendEngine2/zend_objects.c:1.56.2.3.2.4 Mon Jun 5 13:58:51 2006
+++ ZendEngine2/zend_objects.c Wed Jul 26 15:29:27 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_objects.c,v 1.56.2.3.2.4 2006/06/05 13:58:51 zeev Exp $ */
+/* $Id: zend_objects.c,v 1.56.2.3.2.5 2006/07/26 15:29:27 dmitry Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -52,7 +52,7 @@
zend_function *destructor = object->ce->destructor;
if (destructor) {
- zval zobj, *obj = &zobj;
+ zval *obj;
zval *old_exception;
if (destructor->op_array.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) {
@@ -85,10 +85,12 @@
}
}
- Z_TYPE(zobj) = IS_OBJECT;
- Z_OBJ_HANDLE(zobj) = handle;
- Z_OBJ_HT(zobj) = &std_object_handlers;
- INIT_PZVAL(obj);
+ MAKE_STD_ZVAL(obj);
+ Z_TYPE_P(obj) = IS_OBJECT;
+ Z_OBJ_HANDLE_P(obj) = handle;
+ /* TODO: We cannot set proper handlers. */
+ Z_OBJ_HT_P(obj) = &std_object_handlers;
+ zval_copy_ctor(obj);
/* Make sure that destructors are protected from previously thrown exceptions.
* For example, if an exception was thrown in a function and when the function's
@@ -103,6 +105,7 @@
zval *file = zend_read_property(default_exception_ce, old_exception, "file",
sizeof("file")-1, 1 TSRMLS_CC);
zval *line = zend_read_property(default_exception_ce, old_exception, "line",
sizeof("line")-1, 1 TSRMLS_CC);
+ zval_ptr_dtor(&obj);
zval_ptr_dtor(&EG(exception));
EG(exception) = old_exception;
zend_error(E_ERROR, "Ignoring exception from %s::__destruct() while an exception is
already active (Uncaught %s in %s on line %ld)",
@@ -110,6 +113,7 @@
}
EG(exception) = old_exception;
}
+ zval_ptr_dtor(&obj);
}
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug38220.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug38220.phpt
+++ ZendEngine2/tests/bug38220.phpt