Skip to content

Commit 2af1d36

Browse files
committed
Skip special function optimization for redeclared disabled functions
As pointed out on GH-5817.
1 parent f1a3434 commit 2af1d36

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Zend/tests/bug79382.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ disable_functions=strlen
66
<?php
77

88
function strlen(string $x): int {
9-
$len = 0;
10-
while (isset($x[$len])) $len++;
11-
return $len;
9+
return 42;
1210
}
1311

1412
var_dump(strlen("foobar"));
1513

1614
?>
1715
--EXPECT--
18-
int(6)
16+
int(42)

Zend/zend_compile.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,6 +3954,12 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l
39543954
return FAILURE;
39553955
}
39563956

3957+
if (fbc->type != ZEND_INTERNAL_FUNCTION) {
3958+
/* If the function is part of disabled_functions, it may be redeclared as a userland
3959+
* function with a different implementation. Don't use the VM builtin in that case. */
3960+
return FAILURE;
3961+
}
3962+
39573963
if (zend_args_contain_unpack(args)) {
39583964
return FAILURE;
39593965
}

0 commit comments

Comments
 (0)