From 9e8d7749746a8bf293fcfb17d9899b948c4eea0e Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 9 Dec 2024 23:05:51 +0900 Subject: [PATCH] fix: potential memory leak during parameter preparation - 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. --- rayaop.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rayaop.c b/rayaop.c index f99d373..2610602 100644 --- a/rayaop.c +++ b/rayaop.c @@ -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(¶ms[2], arg); + if (add_next_index_zval(¶ms[2], arg) == FAILURE) { + Z_TRY_DELREF_P(arg); + break; + } } } }