com php-src: Improve fix for bug #73807: main/php_variables .c

[email protected] (Nikita Popov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    bbfa1b64192fe3ccd2898e6e1f997387b4f210d1
Author:    Nikita Popov <[email protected]>         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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.