com php-src: fix premature freeing of BG(locale_string) : ext/standard/string.c
| From: | Anatol Belski | Date: | Tue, 20 Jan 2015 15:54:04 +0000 |
| Subject: | com php-src: fix premature freeing of BG(locale_string) : ext/standard/string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84207@lists.php.net to get a copy of this message | ||
Commit: ea8415114a9299f6ba7df16c882e6d9d328af054
Author: Anatol Belski <ab@php.net> Tue, 20 Jan 2015 16:52:49 +0100
Parents: 57162a97bce1f46b3255bea4efb6c1e91c7409ed
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ea8415114a9299f6ba7df16c882e6d9d328af054
Log:
fix premature freeing of BG(locale_string)
the returned string has to be refcounted
Changed paths:
M ext/standard/string.c
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 2c60e20..fc25456 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -4550,12 +4550,11 @@ PHP_FUNCTION(setlocale)
}
if (len == loc->len && !memcmp(loc->val, retval, len)) {
BG(locale_string) = zend_string_copy(loc);
- RETURN_STR(BG(locale_string));
} else {
BG(locale_string) = zend_string_init(retval, len, 0);
zend_string_release(loc);
- RETURN_STR(BG(locale_string));
}
+ RETURN_STR(zend_string_copy(BG(locale_string)));
} else if (len == loc->len && !memcmp(loc->val, retval, len)) {
RETURN_STR(loc);
}