diff options
author | Mark Michelson <mmichelson@digium.com> | 2013-10-18 18:44:21 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2013-10-18 18:44:21 +0000 |
commit | c30170d9a22255e35606a8c506e398f817a5c15c (patch) | |
tree | b2ee714b06705a0ea2e52caefb0fafcbf52bc7f4 /main/sorcery.c | |
parent | 057d105c5ab47f132036a6f54c1dae636a9442bd (diff) |
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
Diffstat (limited to 'main/sorcery.c')
-rw-r--r-- | main/sorcery.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/main/sorcery.c b/main/sorcery.c index 3f2346dfe..3b58188da 100644 --- a/main/sorcery.c +++ b/main/sorcery.c @@ -927,6 +927,7 @@ struct ast_json *ast_sorcery_objectset_json_create(const struct ast_sorcery *sor struct ast_variable *field; if ((res = object_field->multiple_handler(object, &tmp))) { + ao2_ref(object_field, -1); break; } |