[vlc-commits] mmal/codec: Fix buffer leak

Julian Scheel git at videolan.org
Tue Jan 20 07:08:04 CET 2015


vlc | branch: master | Julian Scheel <julian at jusst.de> | Mon Jan 19 11:30:22 2015 +0100| [572e1eb66e8430802a806ec4e5812edfa1c61b40] | committer: Rémi Denis-Courmont

mmal/codec: Fix buffer leak

If buffers were discarded because of wrong size or type a mmal buffer header
would be leaked each time.

Signed-off-by: Julian Scheel <julian at jusst.de>
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=572e1eb66e8430802a806ec4e5812edfa1c61b40
---

 modules/hw/mmal/codec.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/modules/hw/mmal/codec.c b/modules/hw/mmal/codec.c
index b98b6fa..a8e4c31 100644
--- a/modules/hw/mmal/codec.c
+++ b/modules/hw/mmal/codec.c
@@ -408,9 +408,8 @@ static int send_output_buffer(decoder_t *dec)
     picture = decoder_NewPicture(dec);
     if (!picture) {
         msg_Warn(dec, "Failed to get new picture");
-        mmal_buffer_header_release(buffer);
         ret = -1;
-        goto out;
+        goto err;
     }
 
     p_sys = picture->p_sys;
@@ -426,7 +425,7 @@ static int send_output_buffer(decoder_t *dec)
         if (p_sys->buffer == NULL) {
             msg_Err(dec, "Retrieved picture without opaque handle");
             ret = VLC_EGENERIC;
-            goto out;
+            goto err;
         }
         buffer->data = p_sys->buffer->data;
     } else {
@@ -434,7 +433,7 @@ static int send_output_buffer(decoder_t *dec)
             msg_Err(dec, "Retrieved picture with too small data block (%d < %d)",
                     buffer_size, sys->output->buffer_size);
             ret = VLC_EGENERIC;
-            goto out;
+            goto err;
         }
         buffer->data = picture->p[0].p_pixels;
     }
@@ -443,14 +442,18 @@ static int send_output_buffer(decoder_t *dec)
     if (status != MMAL_SUCCESS) {
         msg_Err(dec, "Failed to send buffer to output port (status=%"PRIx32" %s)",
                 status, mmal_status_to_string(status));
-        mmal_buffer_header_release(buffer);
-        picture_Release(picture);
         ret = -1;
-        goto out;
+        goto err;
     }
 
 out:
     return ret;
+
+err:
+    if (picture)
+        picture_Release(picture);
+    mmal_buffer_header_release(buffer);
+    return ret;
 }
 
 static void fill_output_port(decoder_t *dec)



More information about the vlc-commits mailing list