com php-src: Fix memory leak in pcre cache: ext/pcre/php_pcre .c

From: Date: Sun, 09 Sep 2018 08:38:36 +0000
Subject: com php-src: Fix memory leak in pcre cache: ext/pcre/php_pcre .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103032@lists.php.net to get a copy of this message
Commit: 9278be148e751bc6d2107f4df667f6a6de4daa66 Author: Anatol Belski <ab@php.net> Sun, 9 Sep 2018 10:38:36 +0200 Parents: 4905d5e0dfe13fa2645c34352d253b9a1ca11eed Branches: PHP-7.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9278be148e751bc6d2107f4df667f6a6de4daa66 Log: Fix memory leak in pcre cache Changed paths: M ext/pcre/php_pcre.c Diff: diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 3910b41..7aa879d 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -549,6 +549,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) pcre_cache_entry new_entry; int rc; zend_string *key; + pcre_cache_entry *ret; #if HAVE_SETLOCALE if (BG(locale_string) && @@ -843,15 +844,19 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) zend_string *str = zend_string_init(ZSTR_VAL(key), ZSTR_LEN(key), 1); GC_MAKE_PERSISTENT_LOCAL(str); + #if HAVE_SETLOCALE if (key != regex) { zend_string_release_ex(key, 0); } #endif - key = str; + ret = zend_hash_add_new_mem(&PCRE_G(pcre_cache), str, &new_entry, sizeof(pcre_cache_entry)); + zend_string_release(str); + } else { + ret = zend_hash_add_new_mem(&PCRE_G(pcre_cache), key, &new_entry, sizeof(pcre_cache_entry)); } - return zend_hash_add_new_mem(&PCRE_G(pcre_cache), key, &new_entry, sizeof(pcre_cache_entry)); + return ret; } /* }}} */

« previous php.cvs (#103032) next »