X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fsubtitle.c;h=6a5c9383e64cd17a1d30cabf207c91c497e2422f;hb=08be58ddca5bfc5dbba58928f936934d6350426b;hp=15257bf75a43a9514fdccb725da16ed0022137b9;hpb=fe087a38282e93addb25fa9598393e40ea233b09;p=vlc diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c index 15257bf75a..6a5c9383e6 100644 --- a/modules/demux/subtitle.c +++ b/modules/demux/subtitle.c @@ -318,6 +318,7 @@ static int Open ( vlc_object_t *p_this ) if( p_sys->i_type == SUB_TYPE_UNKNOWN ) { msg_Err( p_demux, "failed to recognize subtitle type" ); + free( p_sys ); return VLC_EGENERIC; } @@ -347,6 +348,10 @@ static int Open ( vlc_object_t *p_this ) sizeof(subtitle_t) * i_max ) ) ) { msg_Err( p_demux, "out of memory"); + if( p_sys->subtitle != NULL ) + free( p_sys->subtitle ); + TextUnload( &p_sys->txt ); + free( p_sys ); return VLC_ENOMEM; } } @@ -628,7 +633,7 @@ static int TextLoad( text_t *txt, stream_t *s ) if( txt->i_line_count >= i_line_max ) { i_line_max += 100; - txt->line = realloc( txt->line, i_line_max * sizeof( char*) ); + txt->line = realloc( txt->line, i_line_max * sizeof( char * ) ); } } @@ -991,12 +996,12 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle ) if( p_sys->psz_header != NULL ) { if( !( p_sys->psz_header = realloc( p_sys->psz_header, - strlen( p_sys->psz_header ) + strlen( s ) + 2 ) ) ) + strlen( p_sys->psz_header ) + 1 + strlen( s ) + 2 ) ) ) { msg_Err( p_demux, "out of memory"); return VLC_ENOMEM; } - p_sys->psz_header = strcat( p_sys->psz_header, strdup( s ) ); + p_sys->psz_header = strcat( p_sys->psz_header, s ); p_sys->psz_header = strcat( p_sys->psz_header, "\n" ); } else @@ -1006,7 +1011,7 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle ) msg_Err( p_demux, "out of memory"); return VLC_ENOMEM; } - p_sys->psz_header = strdup( s ); + p_sys->psz_header = s; p_sys->psz_header = strcat( p_sys->psz_header, "\n" ); } }