Skip to content

Commit dd50804

Browse files
committed
Avoid repeated processing of internal functions
Internal functions, when inherited, may (on PHP 8.1 with opcache at least) have pointers which are into heap memory which is local to a given process (e.g. attributes), not present on the target process. Thus accessing the attributes of a duplicated internal functions will crash there. And on top of that, we anyway don't want to process these twice. Signed-off-by: Bob Weinand <[email protected]>
1 parent 8d0cf27 commit dd50804

File tree

1 file changed

+8
-2
lines changed
  • zend_abstract_interface/hook

1 file changed

+8
-2
lines changed

zend_abstract_interface/hook/hook.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,13 @@ static inline void zai_hook_resolve(HashTable *base_ht, zend_class_entry *ce, ze
816816

817817
if (function->common.scope == ce || !ZEND_USER_CODE(function->type)) {
818818
zai_hook_resolve_lookup_inherited(hooks, ce, function, lcname);
819+
}
820+
819821
#if PHP_VERSION_ID >= 80000
822+
if (function->common.scope == ce) {
820823
zai_hook_on_function_resolve(function);
821-
#endif
822824
}
825+
#endif
823826
}
824827

825828
/* {{{ */
@@ -840,10 +843,13 @@ void zai_hook_resolve_class(zend_class_entry *ce, zend_string *lcname) {
840843
zai_store_func_location(function);
841844
if (function->common.scope == ce || !ZEND_USER_CODE(function->type)) {
842845
zai_hook_resolve_lookup_inherited(NULL, ce, function, fnname);
846+
}
847+
843848
#if PHP_VERSION_ID >= 80000
849+
if (function->common.scope == ce) {
844850
zai_hook_on_function_resolve(function);
845-
#endif
846851
}
852+
#endif
847853
} ZEND_HASH_FOREACH_END();
848854
return;
849855
}

0 commit comments

Comments
 (0)