Skip to content

Commit 7daf8b2

Browse files
committed
Fix function overloading
1 parent 842c722 commit 7daf8b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

memprof.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,13 @@ PHP_MINIT_FUNCTION(memprof)
946946

947947
for (fentry = memprof_function_overrides; fentry->fname; fentry++) {
948948
size_t name_len = strlen(fentry->fname);
949-
zend_hash_str_del(CG(function_table), fentry->fname, name_len);
949+
zend_internal_function * orig = zend_hash_str_find_ptr(CG(function_table), fentry->fname, name_len);
950+
if (orig != NULL && orig->type == ZEND_INTERNAL_FUNCTION) {
951+
orig->handler = fentry->handler;
952+
} else {
953+
zend_error(E_WARNING, "memprof: Could not override %s(), return value from this function may be be accurate.", fentry->fname);
954+
}
950955
}
951-
zend_register_functions(NULL, memprof_function_overrides, NULL, type);
952956

953957
return SUCCESS;
954958
}

0 commit comments

Comments
 (0)