Skip to content

Commit c6f117c

Browse files
committed
Use APPLY_STOP in pcre_clean_cache()
Once num_clean has reached 0, we never remove any more elements anyway. Closes GH-15839
1 parent 025ed70 commit c6f117c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/pcre/php_pcre.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,10 @@ static int pcre_clean_cache(zval *data, void *arg)
521521
pcre_cache_entry *pce = (pcre_cache_entry *) Z_PTR_P(data);
522522
int *num_clean = (int *)arg;
523523

524-
if (*num_clean > 0 && !pce->refcount) {
525-
(*num_clean)--;
524+
if (!pce->refcount) {
525+
if (--(*num_clean) == 0) {
526+
return ZEND_HASH_APPLY_REMOVE|ZEND_HASH_APPLY_STOP;
527+
}
526528
return ZEND_HASH_APPLY_REMOVE;
527529
} else {
528530
return ZEND_HASH_APPLY_KEEP;

0 commit comments

Comments
 (0)