From: Corey Farrell Date: Thu, 6 Nov 2014 12:12:47 +0000 (+0000) Subject: main/file.c: fix possible extra ast_module_unref to format modules. X-Git-Tag: 12.8.0-rc1~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=276b1a07b4cb3414bf68cac5027f72bc6c22ddbb;p=thirdparty%2Fasterisk.git 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/ ........ Merged revisions 427464 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@427465 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/file.c b/main/file.c index f4018d5373..09ecb94ee6 100644 --- a/main/file.c +++ b/main/file.c @@ -428,6 +428,7 @@ static struct ast_filestream *get_filestream(struct ast_format_def *fmt, FILE *b 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; @@ -456,8 +457,7 @@ static int fn_wrapper(struct ast_filestream *s, const char *comment, enum wrap_f 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;