shithub: libopusenc

Download patch

ref: cfd5d0f362a24fc1e30f1aaad68cc1a043907071
parent: 5e46bb72ed2097047b4ebd5635d3e97435dffe0f
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Mon May 1 11:27:16 EDT 2017

Fix leaks

--- a/examples/opusenc_example.c
+++ b/examples/opusenc_example.c
@@ -31,5 +31,6 @@
     } else break;
   }
   ope_close_and_free(enc);
+  fclose(fin);
   return 0;
 }
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -90,7 +90,6 @@
   OpusHeader header;
   char *comment;
   int comment_length;
-  int os_allocated;
   ogg_stream_state os;
   int stream_is_init;
   int packetno;
@@ -190,7 +189,6 @@
     enc->re = NULL;
   }
   opus_multistream_encoder_ctl(st, OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_20_MS));
-  enc->os_allocated = 0;
   enc->stream_is_init = 0;
   enc->comment = NULL;
   {
@@ -405,9 +403,13 @@
 /* Close/finalize the stream. */
 int ope_close_and_free(OggOpusEnc *enc) {
   finalize_stream(enc);
+  enc->callbacks.close(enc->user_data);
+  free(enc->comment);
   free(enc->buffer);
   opus_multistream_encoder_destroy(enc->st);
-  if (enc->os_allocated) ogg_stream_clear(&enc->os);
+  if (enc->stream_is_init) ogg_stream_clear(&enc->os);
+  if (enc->re) speex_resampler_destroy(enc->re);
+  free(enc);
   return OPE_OK;
 }