]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a place where filestreams were not refcounted properly
authorMark Michelson <mmichelson@digium.com>
Thu, 12 Feb 2009 23:22:44 +0000 (23:22 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 12 Feb 2009 23:22:44 +0000 (23:22 +0000)
This section was already present in trunk and other branches,
but did not exist in 1.4.

(closes issue #14395)
Reported by: ZX81
Patches:
      14395.patch uploaded by putnopvut (license 60)
Tested by: ZX81

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@175407 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/file.c

index 5836e21e3646f77425887e3a927b62ea0f49b46d..faca5a9be9f078fcf5722fe3e9774adbbf225d61 100644 (file)
@@ -729,11 +729,20 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
                        goto return_failure;
                
                fr = s->fmt->read(s, &whennext);
+               if (fr) {
+                       ast_set_flag(fr, AST_FRFLAG_FROM_FILESTREAM);
+                       ao2_ref(s, +1);
+               }
                if (!fr /* stream complete */ || ast_write(s->owner, fr) /* error writing */) {
-                       if (fr)
+                       if (fr) {
                                ast_log(LOG_WARNING, "Failed to write frame\n");
+                               ast_frfree(fr);
+                       }
                        goto return_failure;
                }
+               if (fr) {
+                       ast_frfree(fr);
+               }
        }
        if (whennext != s->lasttimeout) {
 #ifdef HAVE_DAHDI