php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55305
Patch bug55305.patch revision 2011-07-28 00:30 UTC by cataphract@php.net
revision 2011-07-28 00:30 UTC by cataphract@php.net

Patch bug55305.patch for *General Issues Bug #55305

Patch version 2011-07-28 00:30 UTC

Return to Bug #55305 | Download this patch
Patch Revisions:

Developer: cataphract@php.net

Index: Zend/zend_object_handlers.c
===================================================================
--- Zend/zend_object_handlers.c	(revision 313802)
+++ Zend/zend_object_handlers.c	(working copy)
@@ -688,17 +688,21 @@
 #if DEBUG_OBJECT_HANDLERS
 	fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
 #endif
+	
+	/* necessary to store properties in the HashTable, otherwise the double
+	 * indirection pointer returned here can become invalid if the array
+	 * is replaced by the HashTable */
+	if (!zobj->properties) {
+		rebuild_object_properties(zobj);
+	}
 
 	property_info = zend_get_property_info_quick(zobj->ce, member, (zobj->ce->__get != NULL), key TSRMLS_CC);
 
 	if (UNEXPECTED(!property_info) ||
 	    ((EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
 	     property_info->offset >= 0) ?
-	        (zobj->properties ?
-	            ((retval = (zval**)zobj->properties_table[property_info->offset]) == NULL) :
-	            (*(retval = &zobj->properties_table[property_info->offset]) == NULL)) :
-	        (UNEXPECTED(!zobj->properties) ||
-	          UNEXPECTED(zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == FAILURE)))) {
+			((retval = (zval**)zobj->properties_table[property_info->offset]) == NULL) :
+	        (zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == FAILURE))) {
 		zval *new_zval;
 		zend_guard *guard;
 
@@ -712,10 +716,7 @@
 			Z_ADDREF_P(new_zval);
 			if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
 			    property_info->offset >= 0) {
-				if (!zobj->properties) {
-					zobj->properties_table[property_info->offset] = new_zval;
-					retval = &zobj->properties_table[property_info->offset];
-				} else if (zobj->properties_table[property_info->offset]) {
+				if (zobj->properties_table[property_info->offset]) {
 					*(zval**)zobj->properties_table[property_info->offset] = new_zval;
 					retval = (zval**)zobj->properties_table[property_info->offset];
 				} else {
@@ -723,9 +724,6 @@
 					retval = (zval**)zobj->properties_table[property_info->offset];
 				}
 			} else {
-				if (!zobj->properties) {
-					rebuild_object_properties(zobj);
-				}
 				zend_hash_quick_update(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, &new_zval, sizeof(zval *), (void **) &retval);
 			}
 		} else {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 23:01:30 2024 UTC