Skip special function optimization for redeclared disabled functions

As pointed out on GH-5817.
This commit is contained in:
Nikita Popov 2020-07-08 10:10:32 +02:00
parent f1a343439d
commit 2af1d36bc5
2 changed files with 8 additions and 4 deletions

View file

@ -6,13 +6,11 @@ disable_functions=strlen
<?php
function strlen(string $x): int {
$len = 0;
while (isset($x[$len])) $len++;
return $len;
return 42;
}
var_dump(strlen("foobar"));
?>
--EXPECT--
int(6)
int(42)

View file

@ -3954,6 +3954,12 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l
return FAILURE;
}
if (fbc->type != ZEND_INTERNAL_FUNCTION) {
/* If the function is part of disabled_functions, it may be redeclared as a userland
* function with a different implementation. Don't use the VM builtin in that case. */
return FAILURE;
}
if (zend_args_contain_unpack(args)) {
return FAILURE;
}