com php-src: Strlen cleanup (additions for previous one fix): Zend/zend_object_handlers.c Zend/zend_strtod.c
| From: | Xinchen Hui | Date: | Sat, 07 May 2016 07:08:15 +0000 |
| Subject: | com php-src: Strlen cleanup (additions for previous one fix): Zend/zend_object_handlers.c Zend/zend_strtod.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92062@lists.php.net to get a copy of this message | ||
Commit: 29079f263e38ebf76e2ddbd308e001639eb9e3bf
Author: Xinchen Hui <laruence@gmail.com> Sat, 7 May 2016 00:07:04 -0700
Parents: f7439afedaaa4ec15e1940efaa280089714d54cf
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=29079f263e38ebf76e2ddbd308e001639eb9e3bf
Log:
Strlen cleanup (additions for previous one fix)
Probably compilers will do similar optimization
Changed paths:
M Zend/zend_object_handlers.c
M Zend/zend_strtod.c
Diff:
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 9abe387..ba3e84b 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1068,6 +1068,7 @@ ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry
*scope)
ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string
*method_name, int is_static) /* {{{ */
{
+ size_t mname_len;
zend_op_array *func;
zend_function *fbc = is_static ? ce->__callstatic : ce->__call;
@@ -1100,8 +1101,8 @@ ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce,
zend
//??? keep compatibility for "\0" characters
//??? see: Zend/tests/bug46238.phpt
- if (UNEXPECTED(strlen(ZSTR_VAL(method_name)) != ZSTR_LEN(method_name))) {
- func->function_name = zend_string_init(ZSTR_VAL(method_name), strlen(ZSTR_VAL(method_name)),
0);
+ if (UNEXPECTED((mname_len = strlen(ZSTR_VAL(method_name))) != ZSTR_LEN(method_name))) {
+ func->function_name = zend_string_init(ZSTR_VAL(method_name), mname_len, 0);
} else {
func->function_name = zend_string_copy(method_name);
}
diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c
index 8a08632..889a316 100644
--- a/Zend/zend_strtod.c
+++ b/Zend/zend_strtod.c
@@ -4456,7 +4456,7 @@ ZEND_API double zend_oct_strtod(const char *str, const char **endptr)
double value = 0;
int any = 0;
- if (strlen(str) < 1) {
+ if (str[0] == '\0') {
if (endptr != NULL) {
*endptr = str;
}
@@ -4491,7 +4491,7 @@ ZEND_API double zend_bin_strtod(const char *str, const char **endptr)
double value = 0;
int any = 0;
- if (strlen(str) < 2) {
+ if (str[0] == '\0' || str[1] == '\0') {
if (endptr != NULL) {
*endptr = str;
}