mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@401249 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4533,6 +4533,7 @@ static char *complete_bridge_stasis(const char *word, int state)
|
||||
|
||||
if (!strncasecmp(word, snapshot->uniqueid, wordlen) && (++which > state)) {
|
||||
ret = ast_strdup(snapshot->uniqueid);
|
||||
ao2_ref(msg, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user