[Asterisk-code-review] app_confbridge: Fix memory leak on updated menu options. (asterisk[master])

George Joseph asteriskteam at digium.com
Mon Aug 8 05:20:05 CDT 2022


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18887 )

Change subject: app_confbridge: Fix memory leak on updated menu options.
......................................................................

app_confbridge: Fix memory leak on updated menu options.

If the CONFBRIDGE function is used to dynamically set
menu options, a memory leak occurs when a menu option
that has been set is overridden, since the menu entry
is not destroyed before being freed. This ensures that
it is.

Additionally, logic that duplicates the destroy function
is removed in lieu of the destroy function itself.

ASTERISK-28422 #close

Change-Id: I71cfb5c24e636984d41086d1333a416dc12ff995
---
M apps/confbridge/conf_config_parser.c
1 file changed, 2 insertions(+), 4 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index b27adf2..d04bcf9 100644
--- a/apps/confbridge/conf_config_parser.c
+++ b/apps/confbridge/conf_config_parser.c
@@ -1440,10 +1440,7 @@
 
 	/* if adding any of the actions failed, bail */
 	if (res) {
-		struct conf_menu_action *menu_action;
-		while ((menu_action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) {
-			ast_free(menu_action);
-		}
+		conf_menu_entry_destroy(menu_entry);
 		ast_free(menu_entry);
 		return -1;
 	}
@@ -1452,6 +1449,7 @@
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&menu->entries, cur, entry) {
 		if (!strcasecmp(cur->dtmf, menu_entry->dtmf)) {
 			AST_LIST_REMOVE_CURRENT(entry);
+			conf_menu_entry_destroy(cur);
 			ast_free(cur);
 			break;
 		}

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18887
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I71cfb5c24e636984d41086d1333a416dc12ff995
Gerrit-Change-Number: 18887
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220808/7aeeb0dc/attachment.html>


More information about the asterisk-code-review mailing list