Index: main/file.c =================================================================== --- main/file.c (revision 60397) +++ main/file.c (working copy) @@ -413,10 +413,15 @@ s->fmt = f; s->trans = NULL; s->filename = NULL; - if (s->fmt->format < AST_FORMAT_MAX_AUDIO) + if (s->fmt->format < AST_FORMAT_MAX_AUDIO) { + if (chan->stream) + ast_closestream(chan->stream); chan->stream = s; - else + } else { + if (chan->vstream) + ast_closestream(chan->vstream); chan->vstream = s; + } free(fn); break; } @@ -829,7 +834,7 @@ open_wrapper(fs) ) { ast_log(LOG_WARNING, "Unable to open %s\n", fn); if (fs) - free(fs); + ast_free(fs); if (bfile) fclose(bfile); free(fn); @@ -945,7 +950,7 @@ unlink(orig_fn); } if (fs) - free(fs); + ast_free(fs); } fs->trans = NULL; fs->fmt = f;