Skip to content

Commit ffb4405

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

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
@@ -494,8 +494,10 @@ static int pcre_clean_cache(zval *data, void *arg)
494494
pcre_cache_entry *pce = (pcre_cache_entry *) Z_PTR_P(data);
495495
int *num_clean = (int *)arg;
496496

497-
if (*num_clean > 0 && !pce->refcount) {
498-
(*num_clean)--;
497+
if (!pce->refcount) {
498+
if (--(*num_clean) == 0) {
499+
return ZEND_HASH_APPLY_REMOVE|ZEND_HASH_APPLY_STOP;
500+
}
499501
return ZEND_HASH_APPLY_REMOVE;
500502
} else {
501503
return ZEND_HASH_APPLY_KEEP;

0 commit comments

Comments
 (0)