Skip to content

Commit dfed09a

Browse files
committed
Fix off-by-one in ReflectionType::__toString()
Review mistake...
1 parent 9988863 commit dfed09a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ext/reflection/php_reflection.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,14 +3040,16 @@ ZEND_METHOD(reflection_type, __toString)
30403040
if (param->arg_info->type_hint == IS_OBJECT
30413041
&& !zend_string_equals_literal_ci(param->arg_info->class_name, "self")
30423042
&& !zend_string_equals_literal_ci(param->arg_info->class_name, "parent")) {
3043-
str = zend_string_extend(str, ZSTR_LEN(str) + 1, 0);
3044-
memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), ZSTR_LEN(str) + 1);
3043+
size_t orig_len = ZSTR_LEN(str);
3044+
str = zend_string_extend(str, orig_len + 1, 0);
3045+
memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), orig_len + 1);
30453046
ZSTR_VAL(str)[0] = '\\';
30463047
}
30473048

30483049
if (param->arg_info->allow_null) {
3049-
str = zend_string_extend(str, ZSTR_LEN(str) + 1, 0);
3050-
memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), ZSTR_LEN(str) + 1);
3050+
size_t orig_len = ZSTR_LEN(str);
3051+
str = zend_string_extend(str, orig_len + 1, 0);
3052+
memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), orig_len + 1);
30513053
ZSTR_VAL(str)[0] = '?';
30523054
}
30533055

0 commit comments

Comments
 (0)