]> git.sesse.net Git - vlc/commitdiff
Fix potential memleaks (CID 208)
authorRémi Duraffort <ivoire@videolan.org>
Sun, 5 Oct 2008 17:18:29 +0000 (19:18 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Sun, 5 Oct 2008 17:18:29 +0000 (19:18 +0200)
modules/demux/real.c

index 0960c4cddb4ef21dfe62845127227f13276a0a53..f7b71e35b666d99e10f8ff8467a54a1db6597522 100644 (file)
@@ -1491,6 +1491,8 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
             msg_Dbg( p_demux, "        - extra data=%d", fmt.i_extra );
 
             tk = malloc( sizeof( real_track_t ) );
+            if( !tk )
+                return VLC_ENOMEM;
             tk->i_id = i_num;
             tk->fmt = fmt;
             tk->i_frame = 0;
@@ -1527,9 +1529,11 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
             }
 
             /* Check if the calloc went correctly */
-            if( tk->p_subpackets == NULL )
+            if( !tk->p_subpackets && !tk->p_subpackets_timecode)
             {
-                tk->i_subpackets = 0;
+                free( tk->p_subpackets_timecode );
+                free( tk->p_subpackets );
+                free( tk );
                 msg_Err( p_demux, "Can't alloc subpacket" );
                 return VLC_EGENERIC;
             }