Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/pcre/php_pcre.c
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,10 @@ PHP_FUNCTION(preg_replace_callback_array)
zend_argument_type_error(1, "must contain only valid callbacks");
goto error;
}
if (!str_idx_regex) {
zend_argument_type_error(1, "must contain only string patterns as keys");
goto error;
}

ZVAL_COPY_VALUE(&fci.function_name, replace);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
preg_replace_callback_array() invalid pattern
--FILE--
<?php
preg_replace_callback_array(
[42 => function () {}],
'a',
);
?>
--EXPECTF--
Fatal error: Uncaught TypeError: preg_replace_callback_array(): Argument #1 ($pattern) must contain only string patterns as keys in %s:%d
Stack trace:
#0 %s(%d): preg_replace_callback_array(Array, 'a')
#1 {main}
thrown in %s on line %d