[vlc-commits] mkv: fix leak on error

Rémi Denis-Courmont git at videolan.org
Mon Dec 21 22:10:52 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 21 23:09:53 2015 +0200| [bf093863b0542d71e46444c9a7db840ebf69a0f6] | committer: Rémi Denis-Courmont

mkv: fix leak on error

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

 modules/demux/mkv/util.cpp |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mkv/util.cpp b/modules/demux/mkv/util.cpp
index 86bcb6e..acb2d29 100644
--- a/modules/demux/mkv/util.cpp
+++ b/modules/demux/mkv/util.cpp
@@ -57,16 +57,19 @@ int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk )
     do
     {
         n++;
-        p_new_extra = (uint8_t *) realloc(p_new_extra, n*1024);
-        if( !p_new_extra )
+        void *alloc = realloc(p_new_extra, n*1024);
+        if( alloc == NULL )
         {
             msg_Err( p_demux, "Couldn't allocate buffer to inflate data, ignore track %d",
                       tk->i_number );
+            free(p_new_extra);
             inflateEnd( &d_stream );
             free(tk->p_extra_data);
             delete tk;
             return 1;
         }
+
+        p_new_extra = (uint8_t *)alloc;
         d_stream.next_out = &p_new_extra[(n - 1) * 1024];
         d_stream.avail_out = 1024;
         result = inflate(&d_stream, Z_NO_FLUSH);



More information about the vlc-commits mailing list