php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch foreach-copy-get_object_vars for Scripting Engine problem Bug #64555

Patch version 2013-03-31 11:21 UTC

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

Developer: arpad

diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index d61aba1..1316a1a 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1014,10 +1014,18 @@ ZEND_FUNCTION(get_object_vars)
 	while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) {
 		if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
 			if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) {
+				char *prop_name_dup = NULL;
+
 				zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, &prop_len);
+
+				/* copy the prop name since it's potentially inside an interned string */
+				prop_name_dup = estrndup(prop_name, prop_len);
+
 				/* Not separating references */
 				Z_ADDREF_PP(value);
-				add_assoc_zval_ex(return_value, prop_name, prop_len + 1, *value);
+				add_assoc_zval_ex(return_value, prop_name_dup, prop_len + 1, *value);
+
+				efree(prop_name_dup);
 			}
 		}
 		zend_hash_move_forward_ex(properties, &pos);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 05:01:32 2024 UTC