X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fsubtitle.c;h=87a914c2ddc0518a1bea6fccea7b019f8933941f;hb=05492281965ed211badf7e1f4c2220be720d3356;hp=932b897f0651e3a538553d8c26dcfa67bcfe86f0;hpb=d82d3cba7c830c934429b194c7ca200211f4ec9b;p=vlc diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c index 932b897f06..87a914c2dd 100644 --- a/modules/demux/subtitle.c +++ b/modules/demux/subtitle.c @@ -70,12 +70,12 @@ static const char *const ppsz_sub_type[] = "subviewer1" }; -vlc_module_begin(); - set_shortname( N_("Subtitles")); - set_description( N_("Text subtitles parser") ); - set_capability( "demux", 0 ); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_DEMUX ); +vlc_module_begin () + set_shortname( N_("Subtitles")) + set_description( N_("Text subtitles parser") ) + set_capability( "demux", 0 ) + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_DEMUX ) add_float( "sub-fps", 0.0, NULL, N_("Frames per second"), SUB_FPS_LONGTEXT, true ); @@ -85,10 +85,10 @@ vlc_module_begin(); add_string( "sub-type", "auto", NULL, N_("Subtitles format"), SUB_TYPE_LONGTEXT, true ); change_string_list( ppsz_sub_type, NULL, NULL ); - set_callbacks( Open, Close ); + set_callbacks( Open, Close ) - add_shortcut( "subtitle" ); -vlc_module_end(); + add_shortcut( "subtitle" ) +vlc_module_end () /***************************************************************************** * Prototypes: @@ -442,7 +442,7 @@ static int Open ( vlc_object_t *p_this ) /* Quit on unknown subtitles */ if( p_sys->i_type == SUB_TYPE_UNKNOWN ) { - msg_Err( p_demux, "failed to recognize subtitle type" ); + msg_Warn( p_demux, "failed to recognize subtitle type" ); free( p_sys ); return VLC_EGENERIC; } @@ -1655,12 +1655,15 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) } } - while( psz_text[ strlen( psz_text ) - 1 ] == '\\' ) - { + while( psz_text[ strlen( psz_text ) - 1 ] == '\\' ) + { const char *s2 = TextGetLine( txt ); if( !s2 ) + { + free( psz_orig ); return VLC_EGENERIC; + } int i_len = strlen( s2 ); if( i_len == 0 ) @@ -1674,7 +1677,7 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) psz_orig = psz_text; strcat( psz_text, s2 ); - } + } /* Skip the blanks */ while( *psz_text == ' ' || *psz_text == '\t' ) psz_text++; @@ -1850,12 +1853,10 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) int h1 = 0, m1 = 0, s1 = 0, f1 = 0; int h2 = 0, m2 = 0, s2 = 0, f2 = 0; const char *s = TextGetLine( txt ); + free( psz_text ); if( !s ) - { - free( psz_text ); return VLC_EGENERIC; - } psz_text = malloc( strlen( s ) + 1 ); if( !psz_text ) @@ -1876,7 +1877,6 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) psz_begin, psz_text ) != 2) ) /* Line is not recognized */ { - free( psz_text ); continue; } @@ -1894,12 +1894,6 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) } break; } - /* Line is not recognized */ - else - { - free( psz_text ); - continue; - } } /* Get the following Lines */ @@ -1908,7 +1902,10 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) const char *s = TextGetLine( txt ); if( !s ) + { + free( psz_text ); return VLC_EGENERIC; + } int i_len = strlen( s ); if( i_len == 0 ) break;