shithub: libopusenc

Download patch

ref: 0130afaa7ab6141d4d5dad078748dcddf0d63ce8
parent: 40e3c7034f9003326725f114b7530d085e8c1dde
author: Mark Harris <[email protected]>
date: Sat Apr 7 16:54:46 EDT 2018

Fix uninitialized var and memory leak on error

Signed-off-by: Jean-Marc Valin <[email protected]>

--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -636,8 +636,10 @@
       oggp_commit_packet(enc->oggp, nbBytes, granulepos, e_o_s);
       if (e_o_s) ret = oe_flush_page(enc);
       else if (!enc->pull_api) ret = output_pages(enc);
+      else ret = 0;
       if (ret) {
         enc->unrecoverable = OPE_WRITE_FAIL;
+        if (packet_copy) free(packet_copy);
         return;
       }
       if (e_o_s) {
@@ -647,6 +649,7 @@
           ret = enc->callbacks.close(enc->streams->user_data);
           if (ret) {
             enc->unrecoverable = OPE_CLOSE_FAIL;
+            free(packet_copy);
             return;
           }
         }
@@ -654,7 +657,7 @@
         enc->streams = tmp;
         if (!tmp) enc->last_stream = NULL;
         if (enc->last_stream == NULL) {
-          if (packet_copy) free(packet_copy);
+          free(packet_copy);
           return;
         }
         /* We're done with this stream, start the next one. */