com php-src: Fixed memory leak in ext/standard/tests/strings/qu otemeta_basic.php: ext/standard/string.c

From: Date: Tue, 25 Feb 2014 05:08:16 +0000
Subject: com php-src: Fixed memory leak in ext/standard/tests/strings/qu otemeta_basic.php: ext/standard/string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77932@lists.php.net to get a copy of this message
Commit: bfcb3defdda99345e42cfa2988f6312fdfc5b7ed Author: Xinchen Hui <laruence@gmail.com> Tue, 25 Feb 2014 13:08:16 +0800 Parents: f482092cabb82b688a8421ce5a2254e2f6aed5cf Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bfcb3defdda99345e42cfa2988f6312fdfc5b7ed Log: Fixed memory leak in ext/standard/tests/strings/quotemeta_basic.php Changed paths: M ext/standard/string..c Diff: diff --git a/ext/standard/string.c b/ext/standard/string..c index b54b18a..3c6532d 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2557,11 +2557,12 @@ PHP_FUNCTION(substr_replace) Quotes meta characters */ PHP_FUNCTION(quotemeta) { - char *str, *old; + char *old; char *old_end; char *p, *q; char c; int old_len; + zend_string *str; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &old, &old_len) == FAILURE) { return; @@ -2573,9 +2574,9 @@ PHP_FUNCTION(quotemeta) RETURN_FALSE; } - str = safe_emalloc(2, old_len, 1); + str = STR_ALLOC(2 * old_len, 0); - for (p = old, q = str; p != old_end; p++) { + for (p = old, q = str->val; p != old_end; p++) { c = *p; switch (c) { case '.': @@ -2595,10 +2596,10 @@ PHP_FUNCTION(quotemeta) *q++ = c; } } - *q = 0; -//??? RETURN_STRINGL(erealloc(str, q - str + 1), q - str, 0); - RETURN_STRINGL(erealloc(str, q - str + 1), q - str); + *q = '\0'; + + RETURN_STR(STR_REALLOC(str, q - str->val, 0)); } /* }}} */

« previous php.cvs (#77932) next »