php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch quick-hack for PCRE related Bug #69864Patch version 2015-06-17 22:03 UTC Return to Bug #69864 | Download this patchThis patch is obsolete Obsoleted by patches: Patch Revisions:Developer: cmb@php.netext/pcre/php_pcre.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index c3ceb44..1de7938 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -187,13 +187,15 @@ static PHP_MSHUTDOWN_FUNCTION(pcre) /* {{{ static pcre_clean_cache */ static int pcre_clean_cache(zval *data, void *arg) { + /* data is not a zval, but rather the address of a pcre_cache_entry* in PHP 7 */ + pcre_cache_entry *pce = *((pcre_cache_entry **) data); int *num_clean = (int *)arg; - if (*num_clean > 0) { + if (*num_clean > 0 && !pce->refcount) { (*num_clean)--; - return 1; + return ZEND_HASH_APPLY_REMOVE; } else { - return 0; + return ZEND_HASH_APPLY_KEEP; } } /* }}} */ @@ -1017,14 +1019,17 @@ PHPAPI zend_string *php_pcre_replace(zend_string *regex, int limit, int *replace_count) { pcre_cache_entry *pce; /* Compiled regular expression */ + zend_string *result; /* Compile regex or get it from cache. */ if ((pce = pcre_get_compiled_regex_cache(regex)) == NULL) { return NULL; } - - return php_pcre_replace_impl(pce, subject_str, subject, subject_len, replace_val, + pce->refcount++; + result = php_pcre_replace_impl(pce, subject_str, subject, subject_len, replace_val, is_callable_replace, limit, replace_count); + pce->refcount--; + return result; } /* }}} */ |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Thu Nov 21 15:01:30 2024 UTC |