diff options
Diffstat (limited to 'main/file.c')
-rw-r--r-- | main/file.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/main/file.c b/main/file.c index 41131f9ee..8dded8123 100644 --- a/main/file.c +++ b/main/file.c @@ -425,11 +425,17 @@ static void filestream_destructor(void *arg) static struct ast_filestream *get_filestream(struct ast_format_def *fmt, FILE *bfile) { struct ast_filestream *s; - int l = sizeof(*s) + fmt->buf_size + fmt->desc_size; /* total allocation size */ - if ( (s = ao2_alloc(l, filestream_destructor)) == NULL) + + if (!ast_module_running_ref(fmt->module)) { + return NULL; + } + + s = ao2_alloc(l, filestream_destructor); + if (!s) { + ast_module_unref(fmt->module); return NULL; - ast_module_ref(fmt->module); + } s->fmt = fmt; s->f = bfile; |