Skip to content
Snippets Groups Projects
Commit df37b818 authored by Sean Bright's avatar Sean Bright
Browse files

res_musiconhold.c: Plug ref leak caused by ao2_replace() misuse.

ao2_replace() bumps the reference count of the object that is doing the
replacing, which is not what we want. We just want to drop the old ref
on the old object and update the pointer to point to the new object.

Pointed out by George Joseph in #asterisk-dev

Change-Id: Ie8167ed3d4b52b9d1ea2d785f885e8c27206743d
parent 8c247e2a
No related branches found
No related tags found
3 merge requests!138Merge branch asterisk-20.3.0 into devel properly,!123Merge asterisk '20.3.0' into devel,!118Draft: manager: AOC-S support for AOCMessage
......@@ -1209,7 +1209,8 @@ static void moh_parse_options(struct ast_variable *var, struct mohclass *mohclas
/* We don't need to lock here because we are the thread that
* created this mohclass and we haven't published it yet */
ao2_replace(mohclass->files, playlist_entries);
ao2_ref(mohclass->files, -1);
mohclass->files = playlist_entries;
}
}
......@@ -1306,7 +1307,8 @@ static int moh_scan_files(struct mohclass *class) {
AST_VECTOR_COMPACT(files);
ao2_lock(class);
ao2_replace(class->files, files);
ao2_ref(class->files, -1);
class->files = files;
ao2_unlock(class);
return AST_VECTOR_SIZE(files);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment