Skip to content

Commit 8f46842

Browse files
committed
Fix a NULL pointer dereference bug lead by php_pcre_replace_impl()
php_pcre_replace_impl() will return NULL on failure. However in the function zim_RegexIterator_accept(), the return value of php_pcre_replace_impl() is directly used without any check, which could lead to NULL pointer dereference. Fix this by adding a NULL check.
1 parent 0e6d6f8 commit 8f46842

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/spl/spl_iterators.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,9 @@ PHP_METHOD(RegexIterator, accept)
18801880
}
18811881

18821882
result = php_pcre_replace_impl(intern->u.regex.pce, subject, ZSTR_VAL(subject), ZSTR_LEN(subject), replacement_str, -1, &count);
1883+
if (!replacement_str) {
1884+
RETURN_FALSE;
1885+
}
18831886

18841887
if (intern->u.regex.flags & REGIT_USE_KEY) {
18851888
zval_ptr_dtor(&intern->current.key);

0 commit comments

Comments
 (0)