[asterisk-commits] jrose: branch 1.8 r398937 - /branches/1.8/res/res_musiconhold.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 12 11:35:40 CDT 2013


Author: jrose
Date: Thu Sep 12 11:35:37 2013
New Revision: 398937

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=398937
Log:
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)

Modified:
    branches/1.8/res/res_musiconhold.c

Modified: branches/1.8/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_musiconhold.c?view=diff&rev=398937&r1=398936&r2=398937
==============================================================================
--- branches/1.8/res/res_musiconhold.c (original)
+++ branches/1.8/res/res_musiconhold.c Thu Sep 12 11:35:37 2013
@@ -232,8 +232,9 @@
 #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) {
@@ -246,7 +247,7 @@
 			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;
 }




More information about the asterisk-commits mailing list