com php-src: fixed memory leak: ext/standard/string.c
| From: | Anatol Belski | Date: | Thu, 21 Aug 2014 10:13:52 +0000 |
| Subject: | com php-src: fixed memory leak: ext/standard/string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-80711@lists.php.net to get a copy of this message | ||
Commit: 98bb620bfe132fbc3ee6c4e630e859ab6dc8ba78
Author: Anatol Belski <ab@php.net> Thu, 21 Aug 2014 12:13:52 +0200
Parents: 8d6ef99a390f9437e2eda113b04f564c4e94b294
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=98bb620bfe132fbc3ee6c4e630e859ab6dc8ba78
Log:
fixed memory leak
Changed paths:
M ext/standard/string.c
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index e43ec7d..d104ac2 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -872,7 +872,7 @@ PHP_FUNCTION(ltrim)
Wraps buffer to selected number of characters using string break char */
PHP_FUNCTION(wordwrap)
{
- zend_string *text, *breakchar;
+ zend_string *text, *breakchar = NULL, *breakchar_save = NULL;
php_size_t newtextlen, chk;
size_t alloced;
php_int_t current = 0, laststart = 0, lastspace = 0;
@@ -880,12 +880,20 @@ PHP_FUNCTION(wordwrap)
zend_bool docut = 0;
zend_string *newtext;
- breakchar = STR_INIT("\n", 1, 0);
+ breakchar = breakchar_save = STR_INIT("\n", 1, 1);
+ if (!breakchar) {
+ return;
+ }
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|iSb", &text,
&linelength, &breakchar, &docut) == FAILURE) {
+ STR_FREE(breakchar);
return;
}
+ if (breakchar != breakchar_save) {
+ STR_FREE(breakchar_save);
+ }
+
if (text->len == 0) {
RETURN_EMPTY_STRING();
}