]> granicus.if.org Git - php/commitdiff
Skip special function optimization for redeclared disabled functions
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 8 Jul 2020 08:10:32 +0000 (10:10 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 8 Jul 2020 08:11:00 +0000 (10:11 +0200)
As pointed out on GH-5817.

Zend/tests/bug79382.phpt
Zend/zend_compile.c

index bc6099c4e4329f1bc5b0e99f18d45ed80a70726b..5c1abe2d5fc26680526e20c132064643915f4ca2 100644 (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)
index 95342cc8e2768dcf0cf2ef81b6a6d0061ae4733c..205704a6348c05a999b14aff9576cbc9792c3960 100644 (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;
        }