[Asterisk-code-review] test cel: Plug a few ref leaks (asterisk[16])

Kevin Harwell asteriskteam at digium.com
Thu Nov 29 12:57:20 CST 2018


Kevin Harwell has submitted this change and it was merged. ( https://gerrit.asterisk.org/10713 )

Change subject: test_cel:  Plug a few ref leaks
......................................................................

test_cel:  Plug a few ref leaks

These are only a few of the leaks.  The large number of macros
and return paths in this file would make a weeks worth of work
to plug them all.

Change-Id: Ie2369fa944023d44767871c5c30974cb077ffb56
---
M tests/test_cel.c
1 file changed, 10 insertions(+), 2 deletions(-)

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



diff --git a/tests/test_cel.c b/tests/test_cel.c
index 0b17d48..bfa8293 100644
--- a/tests/test_cel.c
+++ b/tests/test_cel.c
@@ -1790,7 +1790,7 @@
 
 static void test_sub(struct ast_event *event)
 {
-	struct ast_event *event_dup = ao2_dup_event(event);
+	RAII_VAR(struct ast_event *, event_dup, ao2_dup_event(event), ao2_cleanup);
 	const char *chan_name;
 	SCOPED_MUTEX(mid_test_lock, &mid_test_sync_lock);
 
@@ -1855,11 +1855,15 @@
  */
 static int test_cel_peer_strings_match(const char *str1, const char *str2)
 {
-	struct ao2_container *intersection = ast_str_container_alloc(11);
+	RAII_VAR(struct ao2_container *, intersection, ast_str_container_alloc(11), ao2_cleanup);
 	RAII_VAR(char *, str1_dup, ast_strdup(str1), ast_free);
 	RAII_VAR(char *, str2_dup, ast_strdup(str2), ast_free);
 	char *chan;
 
+	if (!intersection) {
+		return 1;
+	}
+
 	while ((chan = strsep(&str1_dup, ","))) {
 		ast_str_container_add(intersection, chan);
 	}
@@ -2140,6 +2144,10 @@
 
 	ast_channel_unregister(&test_cel_chan_tech);
 
+	ao2_cleanup(cel_expected_events);
+	cel_expected_events = NULL;
+	ao2_cleanup(cel_received_events);
+	cel_received_events = NULL;
 	ao2_cleanup(cel_test_config);
 	cel_test_config = NULL;
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie2369fa944023d44767871c5c30974cb077ffb56
Gerrit-Change-Number: 10713
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181129/cc73e438/attachment-0001.html>


More information about the asterisk-code-review mailing list