[asterisk-commits] mjordan: trunk r377324 - in /trunk: ./ main/manager.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 6 08:26:17 CST 2012
Author: mjordan
Date: Thu Dec 6 08:26:13 2012
New Revision: 377324
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377324
Log:
Fix memory leak in 'manager show event' when command entered incorrectly
When the CLI command 'manager show event' was run incorrectly and its usage
instructions returned, a reference to the event container was leaked. This
would prevent the container from being reclaimed when Asterisk exits. We now
properly decrement the count on the ao2 object using the nifty RAII_VAR macro.
Thanks to Russell for helping me stumble on this, and Terry for writing that
ridiculously helpful macro.
........
Merged revisions 377319 from http://svn.asterisk.org/svn/asterisk/branches/11
Modified:
trunk/ (props changed)
trunk/main/manager.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=377324&r1=377323&r2=377324
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Thu Dec 6 08:26:13 2012
@@ -7149,7 +7149,7 @@
static char *handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct ao2_container *events;
+ RAII_VAR(struct ao2_container *, events, NULL, ao2_cleanup);
struct ao2_iterator it_events;
struct ast_xml_doc_item *item, *temp;
int length;
@@ -7184,7 +7184,6 @@
ao2_ref(item, -1);
}
ao2_iterator_destroy(&it_events);
- ao2_ref(events, -1);
return match;
}
@@ -7194,7 +7193,6 @@
if (!(item = ao2_find(events, a->argv[3], OBJ_KEY))) {
ast_cli(a->fd, "Could not find event '%s'\n", a->argv[3]);
- ao2_ref(events, -1);
return CLI_SUCCESS;
}
@@ -7234,7 +7232,6 @@
}
ao2_ref(item, -1);
- ao2_ref(events, -1);
return CLI_SUCCESS;
}
More information about the asterisk-commits
mailing list