Fix trampoline leak in array_map

This commit is contained in:
Nikita Popov 2020-08-31 10:14:39 +02:00
parent c8093fe94a
commit e81becce08
3 changed files with 10 additions and 0 deletions

View file

@ -420,6 +420,9 @@ void shutdown_executor(void) /* {{{ */
} }
#endif #endif
/* Check whether anyone is hogging the trampoline. */
ZEND_ASSERT(EG(trampoline).common.function_name == NULL || CG(unclean_shutdown));
EG(ht_iterators_used) = 0; EG(ht_iterators_used) = 0;
zend_shutdown_fpu(); zend_shutdown_fpu();

View file

@ -6092,6 +6092,7 @@ PHP_FUNCTION(array_map)
int ret; int ret;
if (Z_TYPE(arrays[0]) != IS_ARRAY) { if (Z_TYPE(arrays[0]) != IS_ARRAY) {
zend_release_fcall_info_cache(&fci_cache);
zend_argument_type_error(2, "must be of type array, %s given", zend_zval_type_name(&arrays[0])); zend_argument_type_error(2, "must be of type array, %s given", zend_zval_type_name(&arrays[0]));
RETURN_THROWS(); RETURN_THROWS();
} }

View file

@ -13,6 +13,11 @@ $name = "foo" . ($x = "bar");
$cb = [new Test, $name]; $cb = [new Test, $name];
array_map($cb, []); array_map($cb, []);
array_map($cb, [], []); array_map($cb, [], []);
try {
array_map($cb, null);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
array_filter([], $cb); array_filter([], $cb);
array_reduce([], $cb); array_reduce([], $cb);
@ -24,4 +29,5 @@ usort($array, $cb);
?> ?>
===DONE=== ===DONE===
--EXPECT-- --EXPECT--
array_map(): Argument #2 ($array1) must be of type array, null given
===DONE=== ===DONE===