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.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@401248 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2013-10-18 18:33:35 +00:00
parent aa4e8c4ab3
commit 82904b87f3
5 changed files with 6 additions and 0 deletions

View File

@@ -1581,6 +1581,7 @@ char *ast_complete_channels(const char *line, const char *word, int pos, int sta
if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) {
ret = ast_strdup(snapshot->name);
ao2_ref(msg, -1);
break;
}
}