shithub: opus-tools

Download patch

ref: ef79f7a337d7081ac2f6fc3d25db19dd27635b20
parent: 7cebd223c7135263f89627a8aa1aaeeace75be0c
author: Tristan Matthews <le.businessman@gmail.com>
date: Thu Jan 16 07:23:57 EST 2014

opusrtp: fix memory leaks

Signed-off-by: Ralph Giles <giles@mozilla.com>

--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -109,10 +109,12 @@
 
   if (!data) {
     fprintf(stderr, "Couldn't allocate data buffer.\n");
+    free(op);
     return NULL;
   }
   if (!op) {
     fprintf(stderr, "Couldn't allocate Ogg packet.\n");
+    free(data);
     return NULL;
   }
 
@@ -146,10 +148,12 @@
 
   if (!data) {
     fprintf(stderr, "Couldn't allocate data buffer.\n");
+    free(op);
     return NULL;
   }
   if (!op) {
     fprintf(stderr, "Couldn't allocate Ogg packet.\n");
+    free(data);
     return NULL;
   }
 
@@ -804,15 +808,20 @@
   params->stream = malloc(sizeof(ogg_stream_state));
   if (!params->stream) {
     fprintf(stderr, "Couldn't allocate stream struct.\n");
+    free(params);
     return -1;
   }
   if (ogg_stream_init(params->stream, rand()) < 0) {
     fprintf(stderr, "Couldn't initialize Ogg stream state.\n");
+    free(params->stream);
+    free(params);
     return -1;
   }
   params->out = fopen("rtpdump.opus", "wb");
   if (!params->out) {
     fprintf(stderr, "Couldn't open output file.\n");
+    free(params->stream);
+    free(params);
     return -2;
   }
   params->seq = 0;