Skip to content

Commit f6260b3

Browse files
committed
Merge branch 'PHP-5.5'
2 parents 5c7ae74 + 62059c1 commit f6260b3

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

Zend/zend.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
158158
case HASH_KEY_IS_STRING:
159159
if (is_object) {
160160
const char *prop_name, *class_name;
161-
int mangled = zend_unmangle_property_name(string_key, str_len - 1, &class_name, &prop_name);
161+
int prop_len;
162+
int mangled = zend_unmangle_property_name_ex(string_key, str_len - 1, &class_name, &prop_name, &prop_len);
162163

163-
ZEND_PUTS_EX(prop_name);
164+
ZEND_WRITE_EX(prop_name, prop_len);
164165
if (class_name && mangled == SUCCESS) {
165166
if (class_name[0]=='*') {
166167
ZEND_PUTS_EX(":protected");

Zend/zend_builtin_functions.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ ZEND_FUNCTION(get_object_vars)
987987
HashPosition pos;
988988
char *key;
989989
const char *prop_name, *class_name;
990-
uint key_len;
990+
uint key_len, prop_len;
991991
ulong num_index;
992992
zend_object *zobj;
993993

@@ -1014,10 +1014,10 @@ ZEND_FUNCTION(get_object_vars)
10141014
while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) {
10151015
if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
10161016
if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) {
1017-
zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name);
1017+
zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, &prop_len);
10181018
/* Not separating references */
10191019
Z_ADDREF_PP(value);
1020-
add_assoc_zval_ex(return_value, prop_name, strlen(prop_name)+1, *value);
1020+
add_assoc_zval_ex(return_value, prop_name, prop_len + 1, *value);
10211021
}
10221022
}
10231023
zend_hash_move_forward_ex(properties, &pos);

Zend/zend_compile.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -5178,30 +5178,42 @@ static int zend_strnlen(const char* s, int maxlen) /* {{{ */
51785178
}
51795179
/* }}} */
51805180

5181-
ZEND_API int zend_unmangle_property_name(const char *mangled_property, int len, const char **class_name, const char **prop_name) /* {{{ */
5181+
ZEND_API int zend_unmangle_property_name_ex(const char *mangled_property, int len, const char **class_name, const char **prop_name, int *prop_len) /* {{{ */
51825182
{
51835183
int class_name_len;
51845184

51855185
*class_name = NULL;
51865186

51875187
if (mangled_property[0]!=0) {
51885188
*prop_name = mangled_property;
5189+
if (prop_len) {
5190+
*prop_len = len;
5191+
}
51895192
return SUCCESS;
51905193
}
51915194
if (len < 3 || mangled_property[1]==0) {
51925195
zend_error(E_NOTICE, "Illegal member variable name");
51935196
*prop_name = mangled_property;
5197+
if (prop_len) {
5198+
*prop_len = len;
5199+
}
51945200
return FAILURE;
51955201
}
51965202

5197-
class_name_len = zend_strnlen(mangled_property+1, --len - 1) + 1;
5203+
class_name_len = zend_strnlen(mangled_property + 1, --len - 1) + 1;
51985204
if (class_name_len >= len || mangled_property[class_name_len]!=0) {
51995205
zend_error(E_NOTICE, "Corrupt member variable name");
52005206
*prop_name = mangled_property;
5207+
if (prop_len) {
5208+
*prop_len = len + 1;
5209+
}
52015210
return FAILURE;
52025211
}
5203-
*class_name = mangled_property+1;
5204-
*prop_name = (*class_name)+class_name_len;
5212+
*class_name = mangled_property + 1;
5213+
*prop_name = (*class_name) + class_name_len;
5214+
if (prop_len) {
5215+
*prop_len = len - class_name_len;
5216+
}
52055217
return SUCCESS;
52065218
}
52075219
/* }}} */

Zend/zend_compile.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,9 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce);
671671
void zend_class_add_ref(zend_class_entry **ce);
672672

673673
ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, const char *src1, int src1_length, const char *src2, int src2_length, int internal);
674-
ZEND_API int zend_unmangle_property_name(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name);
674+
#define zend_unmangle_property_name(mangled_property, mangled_property_len, class_name, prop_name) \
675+
zend_unmangle_property_name_ex(mangled_property, mangled_property_len, class_name, prop_name, NULL)
676+
ZEND_API int zend_unmangle_property_name_ex(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name, int *prop_len);
675677

676678
#define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
677679
#define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class

Zend/zend_vm_def.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -4270,8 +4270,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
42704270
zend_check_property_access(zobj, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS));
42714271
zend_hash_get_pointer(fe_ht, &EX_T(opline->op1.var).fe.fe_pos);
42724272
if (use_key && key_type != HASH_KEY_IS_LONG) {
4273-
zend_unmangle_property_name(str_key, str_key_len-1, &class_name, &prop_name);
4274-
str_key_len = strlen(prop_name);
4273+
zend_unmangle_property_name_ex(str_key, str_key_len-1, &class_name, &prop_name, &str_key_len);
42754274
str_key = estrndup(prop_name, str_key_len);
42764275
str_key_len++;
42774276
}

Zend/zend_vm_execute.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -13569,8 +13569,7 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
1356913569
zend_check_property_access(zobj, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS));
1357013570
zend_hash_get_pointer(fe_ht, &EX_T(opline->op1.var).fe.fe_pos);
1357113571
if (use_key && key_type != HASH_KEY_IS_LONG) {
13572-
zend_unmangle_property_name(str_key, str_key_len-1, &class_name, &prop_name);
13573-
str_key_len = strlen(prop_name);
13572+
zend_unmangle_property_name_ex(str_key, str_key_len-1, &class_name, &prop_name, &str_key_len);
1357413573
str_key = estrndup(prop_name, str_key_len);
1357513574
str_key_len++;
1357613575
}

0 commit comments

Comments
 (0)