diff options
author | Anatol Belski <ab@php.net> | 2018-09-09 10:38:36 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2018-09-09 10:38:36 +0200 |
commit | 9278be148e751bc6d2107f4df667f6a6de4daa66 (patch) | |
tree | 0743c5b29a21e99166ec539738294e9cccd9c1ed /ext/pcre/php_pcre.c | |
parent | 4905d5e0dfe13fa2645c34352d253b9a1ca11eed (diff) | |
download | php-git-9278be148e751bc6d2107f4df667f6a6de4daa66.tar.gz |
Fix memory leak in pcre cache
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r-- | ext/pcre/php_pcre.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 3910b41fea..7aa879d26d 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; } /* }}} */ |