[asterisk-commits] coreyfarrell: branch 11 r427464 - /branches/11/main/file.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 6 06:10:43 CST 2014


Author: coreyfarrell
Date: Thu Nov  6 06:10:36 2014
New Revision: 427464

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=427464
Log:
main/file.c: fix possible extra ast_module_unref to format modules.

fn_wrapper only adds a reference to the format's module if the file
was able to be opened.  If not this causes an unmatched
ast_module_unref in filestream_destructor.  Move ast_module_ref to
get_stream.

ASTERISK-24492 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4149/

Modified:
    branches/11/main/file.c

Modified: branches/11/main/file.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/file.c?view=diff&rev=427464&r1=427463&r2=427464
==============================================================================
--- branches/11/main/file.c (original)
+++ branches/11/main/file.c Thu Nov  6 06:10:36 2014
@@ -371,6 +371,7 @@
 	int l = sizeof(*s) + fmt->buf_size + fmt->desc_size;	/* total allocation size */
 	if ( (s = ao2_alloc(l, filestream_destructor)) == NULL)
 		return NULL;
+	ast_module_ref(fmt->module);
 	s->fmt = fmt;
 	s->f = bfile;
 
@@ -399,8 +400,7 @@
 	else if (mode == WRAP_REWRITE && f->rewrite && f->rewrite(s, comment))
 		ast_log(LOG_WARNING, "Unable to rewrite format %s\n", f->name);
 	else {
-		/* preliminary checks succeed. update usecount */
-		ast_module_ref(f->module);
+		/* preliminary checks succeed. */
 		ret = 0;
 	}
 	return ret;




More information about the asterisk-commits mailing list