com php-src: Improve fix for bug #73807: main/php_variables .c
| From: | Nikita Popov | Date: | Sat, 25 Feb 2017 11:55:14 +0000 |
| Subject: | com php-src: Improve fix for bug #73807: main/php_variables .c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97179@lists.php.net to get a copy of this message | ||
Commit: bbfa1b64192fe3ccd2898e6e1f997387b4f210d1
Author: Nikita Popov <nikita.ppv@gmail.com> Sat, 25 Feb 2017 12:55:14 +0100
Parents: eac8166bd468a3c7c00b5163f6f86804911b660d
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bbfa1b64192fe3ccd2898e6e1f997387b4f210d1
Log:
Improve fix for bug #73807
At least on some architectures memmove() on FreeBSD does not
short-curcuit if src==dst. Check for it explicitly to avoid
quadratic copying.
Bugs:
https://bugs.php.net/73807
Changed paths:
M main/php_variables.c
Diff:
diff --git a/main/php_variables.c b/main/php_variables.c
index aa6e426..d3cfb7f 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -311,7 +311,7 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof)
}
}
- if (!eof) {
+ if (!eof && ZSTR_VAL(vars->str.s) != vars->ptr) {
memmove(ZSTR_VAL(vars->str.s), vars->ptr, ZSTR_LEN(vars->str.s) = vars->end -
vars->ptr);
}
return SUCCESS;