Skip to content

Commit 88ce1c7

Browse files
committed
Look up func info using function name rather than lcname of call
As we already have the called zend_function here, let's use the name directly, rather than using the lcname of the call. This means that aliases would be handled correctly automatically.
1 parent 97c6d66 commit 88ce1c7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Zend/Optimizer/zend_func_info.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,14 @@ static HashTable func_info;
808808
ZEND_API int zend_func_info_rid = -1;
809809

810810
static uint32_t get_internal_func_info(
811-
const zend_call_info *call_info, const zend_ssa *ssa, zend_string *lcname) {
812-
if (call_info->callee_func->common.scope) {
811+
const zend_call_info *call_info, const zend_ssa *ssa) {
812+
zend_function *callee_func = call_info->callee_func;
813+
if (callee_func->common.scope) {
813814
/* This is a method, not a function. */
814815
return 0;
815816
}
816817

817-
zval *zv = zend_hash_find_ex(&func_info, lcname, 1);
818+
zval *zv = zend_hash_find_ex(&func_info, callee_func->common.function_name, 1);
818819
if (!zv) {
819820
return 0;
820821
}
@@ -837,9 +838,7 @@ ZEND_API uint32_t zend_get_func_info(
837838
*ce_is_instanceof = 0;
838839

839840
if (callee_func->type == ZEND_INTERNAL_FUNCTION) {
840-
zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2));
841-
842-
uint32_t internal_ret = get_internal_func_info(call_info, ssa, lcname);
841+
uint32_t internal_ret = get_internal_func_info(call_info, ssa);
843842
#if !ZEND_DEBUG
844843
if (internal_ret) {
845844
return internal_ret;
@@ -851,14 +850,15 @@ ZEND_API uint32_t zend_get_func_info(
851850

852851
#if ZEND_DEBUG
853852
if (internal_ret) {
853+
zend_string *name = callee_func->common.function_name;
854854
/* Check whether the func_info information is a subset of the information we can
855855
* compute from the specified return type, otherwise it contains redundant types. */
856856
if (internal_ret & ~ret) {
857-
fprintf(stderr, "Inaccurate func info for %s()\n", ZSTR_VAL(lcname));
857+
fprintf(stderr, "Inaccurate func info for %s()\n", ZSTR_VAL(name));
858858
}
859859
/* Check whether the func info is completely redundant with arginfo. */
860860
if (internal_ret == ret) {
861-
fprintf(stderr, "Useless func info for %s()\n", ZSTR_VAL(lcname));
861+
fprintf(stderr, "Useless func info for %s()\n", ZSTR_VAL(name));
862862
}
863863
/* If the return type is not mixed, check that the types match exactly if we exclude
864864
* RC and array information. */
@@ -868,7 +868,7 @@ ZEND_API uint32_t zend_get_func_info(
868868
/* Func info may contain "true" types as well as isolated "null" and "false". */
869869
if (diff && !(diff == MAY_BE_FALSE && (ret & MAY_BE_FALSE))
870870
&& (internal_ret_any & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
871-
fprintf(stderr, "Incorrect func info for %s()\n", ZSTR_VAL(lcname));
871+
fprintf(stderr, "Incorrect func info for %s()\n", ZSTR_VAL(name));
872872
}
873873
}
874874
return internal_ret;

0 commit comments

Comments
 (0)