summaryrefslogtreecommitdiff
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2014-08-21 21:35:58 +0000
committerJonathan Rose <jrose@digium.com>2014-08-21 21:35:58 +0000
commit494698164614372c1c9279d7ab7565269dd71c26 (patch)
tree10e9ef7c66bd9ea46f4863886792535cc50e1e18 /res/res_musiconhold.c
parent12d34bb12fe7e1478f30122b40042fd7746e8bd7 (diff)
res_musiconhold: Fix reference leaks caused when reloading with REF_DEBUG set
Due to a faulty function for debugging reference decrementing, it was possible to reduce the refcount on the wrong object if two moh classes of the same name were in the moh class container. (closes issue ASTERISK-22252) Reported by: Walter Doekes Patches: 18_moh_debug_ref_patch.diff Uploaded by Jonathan Rose (license 6182) ........ Merged revisions 398937 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 421777 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 421779 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 421788 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@421793 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index bc20a3de8..32fda87bf 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -210,8 +210,9 @@ static int reload(void);
#define mohclass_unref(class,string) _mohclass_unref(class, string, __FILE__,__LINE__,__PRETTY_FUNCTION__)
static struct mohclass *_mohclass_unref(struct mohclass *class, const char *tag, const char *file, int line, const char *funcname)
{
- struct mohclass *dup;
- if ((dup = ao2_find(mohclasses, class, OBJ_POINTER))) {
+ struct mohclass *dup = ao2_callback(mohclasses, OBJ_POINTER, ao2_match_by_addr, class);
+
+ if (dup) {
if (__ao2_ref_debug(dup, -1, (char *) tag, (char *) file, line, funcname) == 2) {
FILE *ref = fopen("/tmp/refs", "a");
if (ref) {
@@ -224,7 +225,7 @@ static struct mohclass *_mohclass_unref(struct mohclass *class, const char *tag,
ao2_ref(class, -1);
}
} else {
- ao2_t_ref(class, -1, (char *) tag);
+ __ao2_ref_debug(class, -1, (char *) tag, (char *) file, line, funcname);
}
return NULL;
}