shithub: opus-tools

Download patch

ref: 8b6ca261b783898db319a4f30eca7ecd5d61356b
parent: dbea7e606341b301daeb401010453cc4764ad321
author: Tristan Matthews <tmatth@videolan.org>
date: Mon Jun 13 18:05:58 EDT 2016

opusrtp: don't leak file stream on error

--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -570,6 +570,7 @@
   ret = ogg_sync_init(&oy);
   if (ret < 0) {
     fprintf(stderr, "Couldn't initialize Ogg sync state\n");
+    fclose(in);
     return ret;
   }
   while (!feof(in)) {
@@ -576,6 +577,7 @@
   in_data = ogg_sync_buffer(&oy, in_size);
   if (!in_data) {
     fprintf(stderr, "ogg_sync_buffer failed\n");
+    fclose(in);
     return -1;
   }
   in_read = fread(in_data, 1, in_size, in);
@@ -582,6 +584,7 @@
   ret = ogg_sync_wrote(&oy, in_read);
   if (ret < 0) {
     fprintf(stderr, "ogg_sync_wrote failed\n");
+    fclose(in);
     return ret;
   }
   while (ogg_sync_pageout(&oy, &og) == 1) {
@@ -591,6 +594,7 @@
         ret = ogg_stream_init(&os, ogg_page_serialno(&og));
         if (ret < 0) {
           fprintf(stderr, "ogg_stream_init failed\n");
+          fclose(in);
           return ret;
         }
         headers++;
@@ -597,6 +601,7 @@
       } else if (!ogg_page_bos(&og)) {
         /* We're past the header and haven't found an Opus stream.
          * Time to give up. */
+        fclose(in);
         return 1;
       } else {
         /* try again */
@@ -607,6 +612,7 @@
     ret = ogg_stream_pagein(&os, &og);
     if (ret < 0) {
       fprintf(stderr, "ogg_stream_pagein failed\n");
+      fclose(in);
       return ret;
     }
     /* read and process available packets */