[asterisk-commits] mmichelson: trunk r401249 - in /trunk: ./ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Oct 18 13:44:23 CDT 2013
Author: mmichelson
Date: Fri Oct 18 13:44:21 2013
New Revision: 401249
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=401249
Log:
Resolve some memory leaks due to incorrect for loop / ao2 ref usage.
A common idiom in Asterisk is to due something like:
for (ao2_obj = list_beginning; ao2_obj = next_item; ao2_ref(ao2_obj, -1)) {
...do stuff...
}
This is nice because it automatically takes care of the object references
for you. However, there is a pitfall here. If a break statement is in the
for loop, then the current reference is not cleaned up. In some cases, this
is on purpose, but in others there is a leak. This commit fixes the leak
cases.
........
Merged revisions 401248 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/main/bridge.c
trunk/main/bucket.c
trunk/main/cli.c
trunk/main/manager.c
trunk/main/sorcery.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridge.c?view=diff&rev=401249&r1=401248&r2=401249
==============================================================================
--- trunk/main/bridge.c (original)
+++ trunk/main/bridge.c Fri Oct 18 13:44:21 2013
@@ -4533,6 +4533,7 @@
if (!strncasecmp(word, snapshot->uniqueid, wordlen) && (++which > state)) {
ret = ast_strdup(snapshot->uniqueid);
+ ao2_ref(msg, -1);
break;
}
}
Modified: trunk/main/bucket.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bucket.c?view=diff&rev=401249&r1=401248&r2=401249
==============================================================================
--- trunk/main/bucket.c (original)
+++ trunk/main/bucket.c Fri Oct 18 13:44:21 2013
@@ -520,6 +520,7 @@
if (!bucket_uri || ast_json_array_append(buckets, bucket_uri)) {
res = -1;
+ ao2_ref(uri, -1);
break;
}
}
@@ -544,6 +545,7 @@
if (!file_uri || ast_json_array_append(files, file_uri)) {
res = -1;
+ ao2_ref(uri, -1);
break;
}
}
Modified: trunk/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cli.c?view=diff&rev=401249&r1=401248&r2=401249
==============================================================================
--- trunk/main/cli.c (original)
+++ trunk/main/cli.c Fri Oct 18 13:44:21 2013
@@ -1581,6 +1581,7 @@
if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) {
ret = ast_strdup(snapshot->name);
+ ao2_ref(msg, -1);
break;
}
}
Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=401249&r1=401248&r2=401249
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Fri Oct 18 13:44:21 2013
@@ -3932,6 +3932,7 @@
ast_free(built);
if (!all) {
+ ao2_ref(msg, -1);
break;
}
}
Modified: trunk/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sorcery.c?view=diff&rev=401249&r1=401248&r2=401249
==============================================================================
--- trunk/main/sorcery.c (original)
+++ trunk/main/sorcery.c Fri Oct 18 13:44:21 2013
@@ -927,6 +927,7 @@
struct ast_variable *field;
if ((res = object_field->multiple_handler(object, &tmp))) {
+ ao2_ref(object_field, -1);
break;
}
More information about the asterisk-commits
mailing list