Skip to content

Commit

Permalink
fix: potential memory leak during parameter preparation
Browse files Browse the repository at this point in the history
- Add exception check during parameter array population
- Handle failed array insertion by removing reference
- Add break on failure to prevent further processing

This fixes memory leaks that could occur if exceptions or failures happen while preparing parameters for method interception.
  • Loading branch information
koriym committed Dec 9, 2024
1 parent dea7e8e commit 9e8d774
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rayaop.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,12 @@ static void rayaop_execute_ex(zend_execute_data *execute_data) {
if (args && !EG(exception)) {
for (uint32_t i = 0; i < arg_count; i++) {
zval *arg = &args[i];
if (!Z_ISUNDEF_P(arg)) {
if (!Z_ISUNDEF_P(arg) && !EG(exception)) {
Z_TRY_ADDREF_P(arg);
add_next_index_zval(&params[2], arg);
if (add_next_index_zval(&params[2], arg) == FAILURE) {
Z_TRY_DELREF_P(arg);
break;
}
}
}
}
Expand Down

0 comments on commit 9e8d774

Please sign in to comment.