]> git.sesse.net Git - vlc/blobdiff - modules/demux/vobsub.c
Replace argument = realloc( argument, size ); with realloc_or_free() in modules/...
[vlc] / modules / demux / vobsub.c
index 97a7282093beac13906a1a7d0c14cf6d05bc17e5..4c12222e5bb4d76c22a4126ca2ae909f9a373df6 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_memory.h>
 
 #include <errno.h>
 #include <sys/types.h>
@@ -152,10 +155,12 @@ static int Open ( vlc_object_t *p_this )
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
     p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    assert( p_sys );
     p_sys->i_length = 0;
     p_sys->p_vobsub_stream = NULL;
     p_sys->i_tracks = 0;
     p_sys->track = (vobsub_track_t *)malloc( sizeof( vobsub_track_t ) );
+    assert( p_sys->track );
     p_sys->i_original_frame_width = -1;
     p_sys->i_original_frame_height = -1;
     p_sys->b_palette = false;
@@ -522,7 +527,9 @@ static int ParseVobSubIDX( demux_t *p_demux )
                         language, &i_track_id ) == 2 )
             {
                 p_sys->i_tracks++;
-                p_sys->track = realloc( p_sys->track, sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) );
+                p_sys->track = realloc_or_free( p_sys->track,
+                          sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) );
+                assert( p_sys->track );
                 language[2] = '\0';
 
                 /* Init the track */
@@ -531,6 +538,7 @@ static int ParseVobSubIDX( demux_t *p_demux )
                 current_tk->i_current_subtitle = 0;
                 current_tk->i_subtitles = 0;
                 current_tk->p_subtitles = malloc( sizeof( subtitle_t ) );;
+                assert( current_tk->p_subtitles );
                 current_tk->i_track_id = i_track_id;
                 current_tk->i_delay = (int64_t)0;
 
@@ -581,7 +589,10 @@ static int ParseVobSubIDX( demux_t *p_demux )
                 i_location = loc;
 
                 current_tk->i_subtitles++;
-                current_tk->p_subtitles = realloc( current_tk->p_subtitles, sizeof( subtitle_t ) * (current_tk->i_subtitles + 1 ) );
+                current_tk->p_subtitles =
+                    realloc_or_free( current_tk->p_subtitles,
+                      sizeof( subtitle_t ) * (current_tk->i_subtitles + 1 ) );
+                assert( current_tk->p_subtitles );
                 current_sub = &current_tk->p_subtitles[current_tk->i_subtitles - 1];
 
                 current_sub->i_start = i_start * i_sign;