Skip to content

Commit

Permalink
Fix arginfo memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Dec 27, 2024
1 parent 0ce8773 commit a0a1ed8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ struct real_func {
zend_function *function;
zif_handler ori_handler;
zend_internal_arg_info *ori_arg_info;
zend_internal_arg_info *arg_info_copy;
uint32_t ori_fn_flags;
uint32_t ori_num_args;
zend_fcall_info_cache *fci_cache;
Expand Down Expand Up @@ -1995,6 +1996,7 @@ static void hook_func(const char *name, size_t l_name, zif_handler handler, zend
zf->internal_function.handler = handler;
if (arg_info) {
zf->internal_function.arg_info = copy_arginfo(zf, arg_info);
rf->arg_info_copy = zf->internal_function.arg_info;
}

if (use_php_func) {
Expand Down Expand Up @@ -2022,6 +2024,10 @@ static void unhook_func(const char *name, size_t l_name) {
if (rf == nullptr) {
return;
}
if (rf->arg_info_copy) {
zend_free_internal_arg_info(&rf->function->internal_function);
rf->arg_info_copy = nullptr;
}
rf->function->internal_function.handler = rf->ori_handler;
rf->function->internal_function.arg_info = rf->ori_arg_info;
}
Expand Down

0 comments on commit a0a1ed8

Please sign in to comment.