[asterisk-commits] mmichelson: branch 12 r401248 - /branches/12/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Oct 18 13:33:39 CDT 2013
Author: mmichelson
Date: Fri Oct 18 13:33:35 2013
New Revision: 401248
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=401248
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.
Modified:
branches/12/main/bridge.c
branches/12/main/bucket.c
branches/12/main/cli.c
branches/12/main/manager.c
branches/12/main/sorcery.c
Modified: branches/12/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/bridge.c?view=diff&rev=401248&r1=401247&r2=401248
==============================================================================
--- branches/12/main/bridge.c (original)
+++ branches/12/main/bridge.c Fri Oct 18 13:33:35 2013
@@ -4533,6 +4533,7 @@
if (!strncasecmp(word, snapshot->uniqueid, wordlen) && (++which > state)) {
ret = ast_strdup(snapshot->uniqueid);
+ ao2_ref(msg, -1);
break;
}
}
Modified: branches/12/main/bucket.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/bucket.c?view=diff&rev=401248&r1=401247&r2=401248
==============================================================================
--- branches/12/main/bucket.c (original)
+++ branches/12/main/bucket.c Fri Oct 18 13:33:35 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: branches/12/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/cli.c?view=diff&rev=401248&r1=401247&r2=401248
==============================================================================
--- branches/12/main/cli.c (original)
+++ branches/12/main/cli.c Fri Oct 18 13:33:35 2013
@@ -1581,6 +1581,7 @@
if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) {
ret = ast_strdup(snapshot->name);
+ ao2_ref(msg, -1);
break;
}
}
Modified: branches/12/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/manager.c?view=diff&rev=401248&r1=401247&r2=401248
==============================================================================
--- branches/12/main/manager.c (original)
+++ branches/12/main/manager.c Fri Oct 18 13:33:35 2013
@@ -3932,6 +3932,7 @@
ast_free(built);
if (!all) {
+ ao2_ref(msg, -1);
break;
}
}
Modified: branches/12/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/sorcery.c?view=diff&rev=401248&r1=401247&r2=401248
==============================================================================
--- branches/12/main/sorcery.c (original)
+++ branches/12/main/sorcery.c Fri Oct 18 13:33:35 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