On 15.09.2005 03:24, Antony Dovgal wrote:
On 14.09.2005 15:20, Zeev Suraski wrote:
Any last minute additions to 5.1.0RC2 or can we roll it?

If it's not too late I'd like to fix http://bugs.php.net/bug.php?id=34505 
before RC2.

It'll require addition of zend_unmangle_property_name_ex() and changing several files to use it instead of zend_unmangle_property_name() (nothing serious though), as the latter may lead to segfaults etc.

I'll post the patch in the morning.

Ok, here it is (divided into two parts).

--
Wbr, Antony Dovgal
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.647.2.4
diff -u -p -d -r1.647.2.4 zend_compile.c
--- Zend/zend_compile.c 9 Sep 2005 06:48:47 -0000       1.647.2.4
+++ Zend/zend_compile.c 15 Sep 2005 15:01:58 -0000
@@ -2065,7 +2065,7 @@ static zend_bool do_inherit_property_acc
                                        if (zend_hash_find(ht, 
child_info->name, child_info->name_length+1, (void**)&new_prop) == SUCCESS) {
                                                if (Z_TYPE_PP(new_prop) != 
IS_NULL && Z_TYPE_PP(prop) != IS_NULL) {
                                                        char *prop_name, *tmp;
-                                                       
zend_unmangle_property_name(child_info->name, &tmp, &prop_name);
+                                                       
zend_unmangle_property_name_ex(child_info->name, child_info->name_length, &tmp, 
&prop_name);
                                                
                                                        
zend_error(E_COMPILE_ERROR, "Cannot change initial value of property static 
protected %s::$%s in class %s", 
                                                                
parent_ce->name, prop_name, ce->name);
@@ -2814,6 +2814,18 @@ ZEND_API void zend_mangle_property_name(
 }
 
 
+ZEND_API void zend_unmangle_property_name_ex(char *mangled_property, int 
mangled_property_len, char **class_name, char **prop_name)
+{
+       *prop_name = *class_name = NULL;
+
+       if (mangled_property_len < 2) { /* do not try to unmangle empty strings 
*/
+               *prop_name = mangled_property;
+               return;
+       }
+       
+       zend_unmangle_property_name(mangled_property, class_name, prop_name);
+}
+
 ZEND_API void zend_unmangle_property_name(char *mangled_property, char 
**class_name, char **prop_name)
 {
        *prop_name = *class_name = NULL;
Index: Zend/zend_compile.h
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.h,v
retrieving revision 1.316.2.2
diff -u -p -d -r1.316.2.2 zend_compile.h
--- Zend/zend_compile.h 9 Sep 2005 06:48:48 -0000       1.316.2.2
+++ Zend/zend_compile.h 15 Sep 2005 15:03:50 -0000
@@ -522,6 +522,7 @@ void zend_class_add_ref(zend_class_entry
 
 ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, char 
*src1, int src1_length, char *src2, int src2_length, int internal);
 ZEND_API void zend_unmangle_property_name(char *mangled_property, char 
**prop_name, char **class_name);
+ZEND_API void zend_unmangle_property_name_ex(char *mangled_property, int 
mangled_property_len, char **prop_name, char **class_name);
 
 #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
 #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
Index: Zend/zend_builtin_functions.c
===================================================================
RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v
retrieving revision 1.277.2.4
diff -u -p -d -r1.277.2.4 zend_builtin_functions.c
--- Zend/zend_builtin_functions.c       9 Sep 2005 06:48:47 -0000       
1.277.2.4
+++ Zend/zend_builtin_functions.c       15 Sep 2005 15:03:51 -0000
@@ -690,7 +690,7 @@ static void add_class_vars(zend_class_en
 
                        zend_hash_get_current_key_ex(properties, &key, 
&key_len, &num_index, 0, &pos);
                        zend_hash_move_forward_ex(properties, &pos);
-                       zend_unmangle_property_name(key, &class_name, 
&prop_name);
+                       zend_unmangle_property_name_ex(key, key_len, 
&class_name, &prop_name);
                        if (class_name) {
                                if (class_name[0] != '*' && strcmp(class_name, 
ce->name)) {
                                        /* filter privates from base classes */
@@ -782,7 +782,7 @@ ZEND_FUNCTION(get_object_vars)
                                (*value)->refcount++;
                                add_assoc_zval_ex(return_value, key, key_len, 
*value);
                        } else if (instanceof) {
-                               zend_unmangle_property_name(key, &class_name, 
&prop_name);
+                               zend_unmangle_property_name_ex(key, key_len, 
&class_name, &prop_name);
                                if (!memcmp(class_name, "*", 2) || 
(Z_OBJCE_P(EG(This)) == Z_OBJCE_PP(obj) && !strcmp(Z_OBJCE_P(EG(This))->name, 
class_name))) {
                                        /* Not separating references */
                                        (*value)->refcount++;
@@ -931,7 +931,7 @@ ZEND_FUNCTION(property_exists)
                if (property_info->flags & ZEND_ACC_PUBLIC) {
                        RETURN_TRUE;
                }
-               zend_unmangle_property_name(property_info->name, &class_name, 
&prop_name);
+               zend_unmangle_property_name_ex(property_info->name, 
property_info->name_length, &class_name, &prop_name);
                if (!strncmp(class_name, "*", 1)) {
                        if (instanceof_function(EG(scope), ce TSRMLS_CC)) {
                                RETURN_TRUE;
Index: Zend/zend_reflection_api.c
===================================================================
RCS file: /repository/ZendEngine2/zend_reflection_api.c,v
retrieving revision 1.164.2.4
diff -u -p -d -r1.164.2.4 zend_reflection_api.c
--- Zend/zend_reflection_api.c  1 Sep 2005 10:05:32 -0000       1.164.2.4
+++ Zend/zend_reflection_api.c  15 Sep 2005 15:03:51 -0000
@@ -720,7 +720,7 @@ static void _property_string(string *str
                        string_printf(str, "static ");
                }
 
-               zend_unmangle_property_name(prop->name, &class_name, 
&prop_name);
+               zend_unmangle_property_name_ex(prop->name, prop->name_length, 
&class_name, &prop_name);
                string_printf(str, "$%s", prop_name);
        }
 
@@ -978,7 +978,7 @@ static void reflection_property_factory(
        property_reference *reference;
        char *class_name, *prop_name;
 
-       zend_unmangle_property_name(prop->name, &class_name, &prop_name);
+       zend_unmangle_property_name_ex(prop->name, prop->name_length, 
&class_name, &prop_name);
 
        if (!(prop->flags & ZEND_ACC_PRIVATE)) {
                /* we have to seach the class hierarchy for this (implicit) 
public or protected property */
@@ -2457,7 +2457,7 @@ ZEND_METHOD(reflection_class, getDefault
 
                        zend_hash_get_current_key_ex(&ce->default_properties, 
&key, &key_len, &num_index, 0, &pos);
                        zend_hash_move_forward_ex(&ce->default_properties, 
&pos);
-                       zend_unmangle_property_name(key, &class_name, 
&prop_name);
+                       zend_unmangle_property_name_ex(key, key_len, 
&class_name, &prop_name);
                        if (class_name && class_name[0] != '*' && 
strcmp(class_name, ce->name)) {
                                /* filter privates from base classes */
                                continue;
@@ -3311,7 +3311,7 @@ ZEND_METHOD(reflection_property, __const
        ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
        zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void 
**) &classname, sizeof(zval *), NULL);
        
-       zend_unmangle_property_name(property_info->name, &class_name, 
&prop_name);
+       zend_unmangle_property_name_ex(property_info->name, 
property_info->name_length, &class_name, &prop_name);
        MAKE_STD_ZVAL(propname);
        ZVAL_STRING(propname, prop_name, 1);
        zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) 
&propname, sizeof(zval *), NULL);
Index: Zend/zend_vm_def.h
===================================================================
RCS file: /repository/ZendEngine2/zend_vm_def.h,v
retrieving revision 1.59.2.5
diff -u -p -d -r1.59.2.5 zend_vm_def.h
--- Zend/zend_vm_def.h  24 Aug 2005 10:41:04 -0000      1.59.2.5
+++ Zend/zend_vm_def.h  15 Sep 2005 15:03:51 -0000
@@ -3110,7 +3110,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, 
                                zend_hash_move_forward(fe_ht);
                        } while (key_type != HASH_KEY_IS_STRING || 
zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS);
                        if (use_key) {
-                               zend_unmangle_property_name(str_key, 
&class_name, &prop_name);
+                               zend_unmangle_property_name_ex(str_key, 
str_key_len, &class_name, &prop_name);
                                str_key_len = strlen(prop_name);
                                str_key = estrndup(prop_name, str_key_len);
                                str_key_len++;
Index: Zend/zend_vm_execute.h
===================================================================
RCS file: /repository/ZendEngine2/zend_vm_execute.h,v
retrieving revision 1.62.2.5
diff -u -p -d -r1.62.2.5 zend_vm_execute.h
--- Zend/zend_vm_execute.h      24 Aug 2005 10:41:04 -0000      1.62.2.5
+++ Zend/zend_vm_execute.h      15 Sep 2005 15:03:53 -0000
@@ -7598,7 +7598,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLE
                                zend_hash_move_forward(fe_ht);
                        } while (key_type != HASH_KEY_IS_STRING || 
zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS);
                        if (use_key) {
-                               zend_unmangle_property_name(str_key, 
&class_name, &prop_name);
+                               zend_unmangle_property_name_ex(str_key, 
str_key_len, &class_name, &prop_name);
                                str_key_len = strlen(prop_name);
                                str_key = estrndup(prop_name, str_key_len);
                                str_key_len++;
Index: ext/soap/php_encoding.c
===================================================================
RCS file: /repository/php-src/ext/soap/php_encoding.c,v
retrieving revision 1.103.2.1
diff -u -p -d -r1.103.2.1 php_encoding.c
--- ext/soap/php_encoding.c     24 Aug 2005 11:46:11 -0000      1.103.2.1
+++ ext/soap/php_encoding.c     15 Sep 2005 15:03:53 -0000
@@ -1669,9 +1669,9 @@ static xmlNodePtr to_xml_object(encodeTy
                                zval **zprop;
                                char *str_key;
                                ulong index;
-                               int key_type;
+                               int key_type, str_key_len;
 
-                               key_type = zend_hash_get_current_key(prop, 
&str_key, &index, FALSE);
+                               key_type = zend_hash_get_current_key_ex(prop, 
&str_key, &str_key_len, &index, FALSE, NULL);
                                zend_hash_get_current_data(prop, (void 
**)&zprop);
 
                                property = 
master_to_xml(get_conversion((*zprop)->type), (*zprop), style, xmlParam);
@@ -1682,7 +1682,7 @@ static xmlNodePtr to_xml_object(encodeTy
                                        if (Z_TYPE_P(data) == IS_OBJECT) {
                                                char *class_name;
 
-                                               
zend_unmangle_property_name(str_key, &class_name, &prop_name);
+                                               
zend_unmangle_property_name_ex(str_key, str_key_len, &class_name, &prop_name);
                                        } else {
                                                prop_name = str_key;
                                        }
Index: ext/standard/http.c
===================================================================
RCS file: /repository/php-src/ext/standard/http.c,v
retrieving revision 1.14
diff -u -p -d -r1.14 http.c
--- ext/standard/http.c 3 Aug 2005 14:08:04 -0000       1.14
+++ ext/standard/http.c 15 Sep 2005 15:03:53 -0000
@@ -69,7 +69,7 @@ PHPAPI int php_url_encode_hash_ex(HashTa
                                /* private or protected property access outside 
of the class */
                                continue;
                        }
-                       zend_unmangle_property_name(key, &tmp, &key);
+                       zend_unmangle_property_name_ex(key, key_len, &tmp, 
&key);
                        key_len = strlen(key);          
                }
 
Index: ext/standard/var.c
===================================================================
RCS file: /repository/php-src/ext/standard/var.c,v
retrieving revision 1.203.2.2
diff -u -p -d -r1.203.2.2 var.c
--- ext/standard/var.c  12 Sep 2005 07:13:54 -0000      1.203.2.2
+++ ext/standard/var.c  15 Sep 2005 15:03:53 -0000
@@ -76,7 +76,7 @@ static int php_object_property_dump(zval
        if (hash_key->nKeyLength ==0 ) { /* numeric key */
                php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
        } else { /* string key */
-               zend_unmangle_property_name(hash_key->arKey, &class_name, 
&prop_name);
+               zend_unmangle_property_name_ex(hash_key->arKey, 
hash_key->nKeyLength, &class_name, &prop_name);
                if (class_name) {
                        php_printf("%*c[\"%s", level + 1, ' ', prop_name);
                        if (class_name[0]=='*') {
@@ -351,7 +351,7 @@ static int php_object_element_export(zva
 
        if (hash_key->nKeyLength != 0) {
                php_printf("%*c", level + 1, ' ');
-               zend_unmangle_property_name(hash_key->arKey, &class_name, 
&prop_name);
+               zend_unmangle_property_name_ex(hash_key->arKey, 
hash_key->nKeyLength, &class_name, &prop_name);
                if (class_name) {
                        if (class_name[0] == '*') {
                                php_printf("protected");
Index: ext/wddx/wddx.c
===================================================================
RCS file: /repository/php-src/ext/wddx/wddx.c,v
retrieving revision 1.119.2.2
diff -u -p -d -r1.119.2.2 wddx.c
--- ext/wddx/wddx.c     31 Aug 2005 14:31:44 -0000      1.119.2.2
+++ ext/wddx/wddx.c     15 Sep 2005 15:03:54 -0000
@@ -524,7 +524,7 @@ static void php_wddx_serialize_object(wd
                        if (zend_hash_get_current_key_ex(HASH_OF(obj), &key, 
&key_len, &idx, 0, NULL) == HASH_KEY_IS_STRING) {
                                char *class_name, *prop_name;
                                
-                               zend_unmangle_property_name(key, &class_name, 
&prop_name);
+                               zend_unmangle_property_name_ex(key, key_len, 
&class_name, &prop_name);
                                php_wddx_serialize_var(packet, *ent, prop_name, 
strlen(prop_name)+1 TSRMLS_CC);
                        } else {
                                key_len = sprintf(tmp_buf, "%ld", idx);

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to