Skip to content

Commit c47011b

Browse files
committed
Use zend_string when storing incomplete class name
No need to copy the string here...
1 parent 1d0f553 commit c47011b

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

ext/standard/incomplete_class.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,11 @@ PHPAPI zend_string *php_lookup_class_name(zend_object *object)
142142
/* }}} */
143143

144144
/* {{{ php_store_class_name */
145-
PHPAPI void php_store_class_name(zval *object, const char *name, size_t len)
145+
PHPAPI void php_store_class_name(zval *object, zend_string *name)
146146
{
147147
zval val;
148148

149-
150-
ZVAL_STRINGL(&val, name, len);
149+
ZVAL_STR_COPY(&val, name);
151150
zend_hash_str_update(Z_OBJPROP_P(object), MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1, &val);
152151
}
153152
/* }}} */

ext/standard/php_incomplete_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extern "C" {
5151

5252
PHPAPI void php_register_incomplete_class(void);
5353
PHPAPI zend_string *php_lookup_class_name(zend_object *object);
54-
PHPAPI void php_store_class_name(zval *object, const char *name, size_t len);
54+
PHPAPI void php_store_class_name(zval *object, zend_string *name);
5555

5656
#ifdef __cplusplus
5757
};

ext/standard/var_unserializer.re

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ use_double:
10131013
}
10141014
10151015
object ":" uiv ":" ["] {
1016-
size_t len, len2, len3, maxlen;
1016+
size_t len, len3, maxlen;
10171017
zend_long elements;
10181018
char *str;
10191019
zend_string *class_name;
@@ -1031,7 +1031,7 @@ object ":" uiv ":" ["] {
10311031
custom_object = 1;
10321032
}
10331033

1034-
len2 = len = parse_uiv(start + 2);
1034+
len = parse_uiv(start + 2);
10351035
maxlen = max - YYCURSOR;
10361036
if (maxlen < len || len == 0) {
10371037
*p = start + 2;
@@ -1143,7 +1143,7 @@ object ":" uiv ":" ["] {
11431143
ret = object_custom(UNSERIALIZE_PASSTHRU, ce);
11441144

11451145
if (ret && incomplete_class) {
1146-
php_store_class_name(rval, ZSTR_VAL(class_name), len2);
1146+
php_store_class_name(rval, class_name);
11471147
}
11481148
zend_string_release_ex(class_name, 0);
11491149
return ret;
@@ -1181,7 +1181,7 @@ object ":" uiv ":" ["] {
11811181
}
11821182

11831183
if (incomplete_class) {
1184-
php_store_class_name(rval, ZSTR_VAL(class_name), len2);
1184+
php_store_class_name(rval, class_name);
11851185
}
11861186
zend_string_release_ex(class_name, 0);
11871187

0 commit comments

Comments
 (0)