com php-src: Fix off-by-one in ReflectionType::__toStri ng(): ext/reflection/php_reflection.c
| From: | Nikita Popov | Date: | Sat, 20 Aug 2016 17:00:03 +0000 |
| Subject: | com php-src: Fix off-by-one in ReflectionType::__toStri ng(): ext/reflection/php_reflection.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94017@lists.php.net to get a copy of this message | ||
Commit: dfed09afcaed6773f00b366b0580a187f2fc453f
Author: Nikita Popov <nikic@php.net> Sat, 20 Aug 2016 19:00:03 +0200
Parents: 9988863d37b67af934a9b8d125b84862d6ca9016
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dfed09afcaed6773f00b366b0580a187f2fc453f
Log:
Fix off-by-one in ReflectionType::__toString()
Review mistake...
Changed paths:
M ext/reflection/php_reflection.c
Diff:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index df15efd..66ffeab 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -3040,14 +3040,16 @@ ZEND_METHOD(reflection_type, __toString)
if (param->arg_info->type_hint == IS_OBJECT
&& !zend_string_equals_literal_ci(param->arg_info->class_name, "self")
&& !zend_string_equals_literal_ci(param->arg_info->class_name, "parent"))
{
- str = zend_string_extend(str, ZSTR_LEN(str) + 1, 0);
- memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), ZSTR_LEN(str) + 1);
+ size_t orig_len = ZSTR_LEN(str);
+ str = zend_string_extend(str, orig_len + 1, 0);
+ memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), orig_len + 1);
ZSTR_VAL(str)[0] = '\\';
}
if (param->arg_info->allow_null) {
- str = zend_string_extend(str, ZSTR_LEN(str) + 1, 0);
- memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), ZSTR_LEN(str) + 1);
+ size_t orig_len = ZSTR_LEN(str);
+ str = zend_string_extend(str, orig_len + 1, 0);
+ memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), orig_len + 1);
ZSTR_VAL(str)[0] = '?';
}