]> granicus.if.org Git - php/commitdiff
fix premature freeing of BG(locale_string)
authorAnatol Belski <ab@php.net>
Tue, 20 Jan 2015 15:52:49 +0000 (16:52 +0100)
committerAnatol Belski <ab@php.net>
Tue, 20 Jan 2015 15:54:04 +0000 (16:54 +0100)
the returned string has to be refcounted

ext/standard/string.c

index 2c60e207fb7ee32e937628d0afa9808122f7a039..fc25456c555e451dd166ac8f1f0f889ba7d3427b 100644 (file)
@@ -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);
                                }