]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Bug 9486 - memory leak when opening a filestream
authorTilghman Lesher <tilghman@meg.abyt.es>
Sun, 8 Apr 2007 01:39:25 +0000 (01:39 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Sun, 8 Apr 2007 01:39:25 +0000 (01:39 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@60660 65c4cc65-6c06-0410-ace0-fbb531ad65f3

file.c

diff --git a/file.c b/file.c
index 1067f7ff3533c87c5fc4a4e25c96c73a93d53c49..15734ecd2e573ab9d20341667ef98f8087f32046 100644 (file)
--- a/file.c
+++ b/file.c
@@ -427,10 +427,15 @@ static int ast_filehelper(const char *filename, const char *filename2, const cha
                                                                                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;
+                                                                               }
                                                                        } else {
                                                                                fclose(bfile);
                                                                                ast_log(LOG_WARNING, "Unable to open file on %s\n", fn);