X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fsubtitle.c;h=b8021d883d0477e6b2d039bb6f651be16a32e606;hb=3118165aefce584687fd67953e477fbbdf7e1bcb;hp=3eef59b035535afcd12b05ee370191f7a040c84e;hpb=903453e34b34b2361bfe7c2e17b1dfc5d544ac6e;p=vlc diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c index 3eef59b035..b8021d883d 100644 --- a/modules/demux/subtitle.c +++ b/modules/demux/subtitle.c @@ -34,11 +34,8 @@ #include #include #include +#include -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif #include #include @@ -61,6 +58,8 @@ static void Close( vlc_object_t *p_this ); "\"sami\", \"dvdsubtitle\", \"mpl2\", \"aqt\", \"pjs\", "\ "\"mpsub\", \"jacosub\", \"psb\", \"realtext\", \"dks\", \"subviewer1\", " \ " and \"auto\" (meaning autodetection, this should always work).") +#define SUB_DESCRIPTION_LONGTEXT \ + N_("Override the default track description.") static const char *const ppsz_sub_type[] = { @@ -70,25 +69,27 @@ 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 ); + SUB_FPS_LONGTEXT, true ) add_integer( "sub-delay", 0, NULL, N_("Subtitles delay"), - SUB_DELAY_LONGTEXT, true ); + SUB_DELAY_LONGTEXT, true ) 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 ); + SUB_TYPE_LONGTEXT, true ) + change_string_list( ppsz_sub_type, NULL, NULL ) + add_string( "sub-description", NULL, NULL, N_("Subtitles description"), + SUB_DESCRIPTION_LONGTEXT, true ) + set_callbacks( Open, Close ) - add_shortcut( "subtitle" ); -vlc_module_end(); + add_shortcut( "subtitle" ) +vlc_module_end () /***************************************************************************** * Prototypes: @@ -98,6 +99,7 @@ enum SUB_TYPE_UNKNOWN = -1, SUB_TYPE_MICRODVD, SUB_TYPE_SUBRIP, + SUB_TYPE_SUBRIP_DOT, /* Invalid SubRip file (dot instead of comma) */ SUB_TYPE_SSA1, SUB_TYPE_SSA2_4, SUB_TYPE_ASS, @@ -172,6 +174,7 @@ struct demux_sys_t static int ParseMicroDvd ( demux_t *, subtitle_t *, int ); static int ParseSubRip ( demux_t *, subtitle_t *, int ); +static int ParseSubRipDot ( demux_t *, subtitle_t *, int ); static int ParseSubViewer ( demux_t *, subtitle_t *, int ); static int ParseSSA ( demux_t *, subtitle_t *, int ); static int ParseVplayer ( demux_t *, subtitle_t *, int ); @@ -197,6 +200,7 @@ static const struct { { "microdvd", SUB_TYPE_MICRODVD, "MicroDVD", ParseMicroDvd }, { "subrip", SUB_TYPE_SUBRIP, "SubRIP", ParseSubRip }, + { "subrip-dot", SUB_TYPE_SUBRIP_DOT, "SubRIP(Dot)", ParseSubRipDot }, { "subviewer", SUB_TYPE_SUBVIEWER, "SubViewer", ParseSubViewer }, { "ssa1", SUB_TYPE_SSA1, "SSA-1", ParseSSA }, { "ssa2-4", SUB_TYPE_SSA2_4, "SSA-2/3/4", ParseSSA }, @@ -222,7 +226,7 @@ static const struct static int Demux( demux_t * ); static int Control( demux_t *, int, va_list ); -/*static void Fix( demux_t * );*/ +static void Fix( demux_t * ); /***************************************************************************** * Module initializer @@ -329,6 +333,15 @@ static int Open ( vlc_object_t *p_this ) p_sys->i_type = SUB_TYPE_SUBRIP; break; } + else if( sscanf( s, + "%d:%d:%d.%d --> %d:%d:%d.%d", + &i_dummy,&i_dummy,&i_dummy,&i_dummy, + &i_dummy,&i_dummy,&i_dummy,&i_dummy ) == 8 ) + { + msg_Err( p_demux, "Detected invalid SubRip file, playing anyway" ); + p_sys->i_type = SUB_TYPE_SUBRIP_DOT; + break; + } else if( !strncasecmp( s, "!: This is a Sub Station Alpha v1", 33 ) ) { p_sys->i_type = SUB_TYPE_SSA1; @@ -442,7 +455,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; } @@ -469,10 +482,9 @@ static int Open ( vlc_object_t *p_this ) if( p_sys->i_subtitles >= i_max ) { i_max += 500; - if( !( p_sys->subtitle = realloc( p_sys->subtitle, + if( !( p_sys->subtitle = realloc_or_free( p_sys->subtitle, sizeof(subtitle_t) * i_max ) ) ) { - free( p_sys->subtitle ); TextUnload( &p_sys->txt ); free( p_sys ); return VLC_ENOMEM; @@ -506,18 +518,25 @@ static int Open ( vlc_object_t *p_this ) p_sys->i_type == SUB_TYPE_SSA2_4 || p_sys->i_type == SUB_TYPE_ASS ) { - es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','s','a',' ' ) ); + Fix( p_demux ); + es_format_Init( &fmt, SPU_ES, VLC_CODEC_SSA ); } else { - es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','u','b','t' ) ); + es_format_Init( &fmt, SPU_ES, VLC_CODEC_SUBT ); } + char *psz_description = var_InheritString( p_demux, "sub-description" ); + if( psz_description && *psz_description ) + fmt.psz_description = psz_description; + else + free( psz_description ); if( p_sys->psz_header != NULL ) { fmt.i_extra = strlen( p_sys->psz_header ) + 1; fmt.p_extra = strdup( p_sys->psz_header ); } p_sys->es = es_out_Add( p_demux->out, &fmt ); + es_format_Clean( &fmt ); return VLC_SUCCESS; } @@ -566,9 +585,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) case DEMUX_SET_TIME: i64 = (int64_t)va_arg( args, int64_t ); p_sys->i_subtitle = 0; - while( p_sys->i_subtitle < p_sys->i_subtitles && - p_sys->subtitle[p_sys->i_subtitle].i_start < i64 ) + while( p_sys->i_subtitle < p_sys->i_subtitles ) { + const subtitle_t *p_subtitle = &p_sys->subtitle[p_sys->i_subtitle]; + + if( p_subtitle->i_start > i64 ) + break; + if( p_subtitle->i_stop > p_subtitle->i_start && p_subtitle->i_stop > i64 ) + break; + p_sys->i_subtitle++; } @@ -616,6 +641,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) case DEMUX_GET_ATTACHMENTS: case DEMUX_GET_TITLE_INFO: case DEMUX_HAS_UNSUPPORTED_META: + case DEMUX_CAN_RECORD: return VLC_EGENERIC; default: @@ -645,12 +671,13 @@ static int Demux( demux_t *p_demux ) while( p_sys->i_subtitle < p_sys->i_subtitles && p_sys->subtitle[p_sys->i_subtitle].i_start < i_maxdate ) { + const subtitle_t *p_subtitle = &p_sys->subtitle[p_sys->i_subtitle]; + block_t *p_block; - int i_len = strlen( p_sys->subtitle[p_sys->i_subtitle].psz_text ) + 1; + int i_len = strlen( p_subtitle->psz_text ) + 1; - if( i_len <= 1 ) + if( i_len <= 1 || p_subtitle->i_start < 0 ) { - /* empty subtitle */ p_sys->i_subtitle++; continue; } @@ -661,30 +688,15 @@ static int Demux( demux_t *p_demux ) continue; } - if( p_sys->subtitle[p_sys->i_subtitle].i_start < 0 ) - { - p_sys->i_subtitle++; - continue; - } + p_block->i_dts = + p_block->i_pts = VLC_TS_0 + p_subtitle->i_start; + if( p_subtitle->i_stop >= 0 && p_subtitle->i_stop >= p_subtitle->i_start ) + p_block->i_length = p_subtitle->i_stop - p_subtitle->i_start; - p_block->i_pts = p_sys->subtitle[p_sys->i_subtitle].i_start; - p_block->i_dts = p_block->i_pts; - if( p_sys->subtitle[p_sys->i_subtitle].i_stop > 0 ) - { - p_block->i_length = - p_sys->subtitle[p_sys->i_subtitle].i_stop - p_block->i_pts; - } + memcpy( p_block->p_buffer, p_subtitle->psz_text, i_len ); + + es_out_Send( p_demux->out, p_sys->es, p_block ); - memcpy( p_block->p_buffer, - p_sys->subtitle[p_sys->i_subtitle].psz_text, i_len ); - if( p_block->i_pts > 0 ) - { - es_out_Send( p_demux->out, p_sys->es, p_block ); - } - else - { - block_Release( p_block ); - } p_sys->i_subtitle++; } @@ -697,12 +709,10 @@ static int Demux( demux_t *p_demux ) /***************************************************************************** * Fix: fix time stamp and order of subtitle *****************************************************************************/ -#ifdef USE_THIS_UNUSED_PIECE_OF_CODE static void Fix( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; bool b_done; - int i_index; /* *** fix order (to be sure...) *** */ /* We suppose that there are near in order and this durty bubble sort @@ -711,10 +721,10 @@ static void Fix( demux_t *p_demux ) do { b_done = true; - for( i_index = 1; i_index < p_sys->i_subtitles; i_index++ ) + for( int i_index = 1; i_index < p_sys->i_subtitles; i_index++ ) { if( p_sys->subtitle[i_index].i_start < - p_sys->subtitle[i_index - 1].i_start ) + p_sys->subtitle[i_index - 1].i_start ) { subtitle_t sub_xch; memcpy( &sub_xch, @@ -731,7 +741,6 @@ static void Fix( demux_t *p_demux ) } } while( !b_done ); } -#endif static int TextLoad( text_t *txt, stream_t *s ) { @@ -742,6 +751,8 @@ static int TextLoad( text_t *txt, stream_t *s ) txt->i_line_count = 0; txt->i_line = 0; txt->line = calloc( i_line_max, sizeof( char * ) ); + if( !txt->line ) + return VLC_ENOMEM; /* load the complete file */ for( ;; ) @@ -755,7 +766,9 @@ 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_or_free( txt->line, i_line_max * sizeof( char * ) ); + if( !txt->line ) + return VLC_ENOMEM; } } @@ -823,7 +836,7 @@ static int ParseMicroDvd( demux_t *p_demux, subtitle_t *p_subtitle, return VLC_ENOMEM; i_start = 0; - i_stop = 0; + i_stop = -1; if( sscanf( s, "{%d}{}%[^\r\n]", &i_start, psz_text ) == 2 || sscanf( s, "{%d}{%d}%[^\r\n]", &i_start, &i_stop, psz_text ) == 3) { @@ -849,7 +862,7 @@ static int ParseMicroDvd( demux_t *p_demux, subtitle_t *p_subtitle, /* */ p_subtitle->i_start = i_start * p_sys->i_microsecperframe; - p_subtitle->i_stop = i_stop * p_sys->i_microsecperframe; + p_subtitle->i_stop = i_stop >= 0 ? (i_stop * p_sys->i_microsecperframe) : -1; p_subtitle->psz_text = psz_text; return VLC_SUCCESS; } @@ -899,7 +912,8 @@ static int ParseSubRipSubViewer( demux_t *p_demux, subtitle_t *p_subtitle, (int64_t)m2 * 60*1000 + (int64_t)s2 * 1000 + (int64_t)d2 ) * 1000; - break; + if( p_subtitle->i_start < p_subtitle->i_stop ) + break; } } @@ -907,19 +921,14 @@ static int ParseSubRipSubViewer( demux_t *p_demux, subtitle_t *p_subtitle, psz_text = strdup(""); if( !psz_text ) return VLC_ENOMEM; + for( ;; ) { const char *s = TextGetLine( txt ); int i_len; int i_old; - if( !s ) - { - free( psz_text ); - return VLC_EGENERIC; - } - - i_len = strlen( s ); + i_len = s ? strlen( s ) : 0; if( i_len <= 0 ) { p_subtitle->psz_text = psz_text; @@ -927,9 +936,11 @@ static int ParseSubRipSubViewer( demux_t *p_demux, subtitle_t *p_subtitle, } i_old = strlen( psz_text ); - psz_text = realloc( psz_text, i_old + i_len + 1 + 1 ); + psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 ); if( !psz_text ) + { return VLC_ENOMEM; + } strcat( psz_text, s ); strcat( psz_text, "\n" ); @@ -956,6 +967,17 @@ static int ParseSubRip( demux_t *p_demux, subtitle_t *p_subtitle, "%d:%d:%d,%d --> %d:%d:%d,%d", false ); } +/* ParseSubRipDot + * Special version for buggy file using '.' instead of ',' + */ +static int ParseSubRipDot( demux_t *p_demux, subtitle_t *p_subtitle, + int i_idx ) +{ + VLC_UNUSED( i_idx ); + return ParseSubRipSubViewer( p_demux, p_subtitle, + "%d:%d:%d.%d --> %d:%d:%d.%d", + false ); +} /* ParseSubViewer */ static int ParseSubViewer( demux_t *p_demux, subtitle_t *p_subtitle, @@ -1042,16 +1064,11 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle, free( psz_text ); /* All the other stuff we add to the header field */ - if( !p_sys->psz_header ) - p_sys->psz_header = strdup( "" ); - if( !p_sys->psz_header ) + char *psz_header; + if( asprintf( &psz_header, "%s%s\n", + p_sys->psz_header ? p_sys->psz_header : "", s ) == -1 ) return VLC_ENOMEM; - - p_sys->psz_header = - realloc( p_sys->psz_header, - strlen( p_sys->psz_header ) + strlen( s ) + 2 ); - strcat( p_sys->psz_header, s ); - strcat( p_sys->psz_header, "\n" ); + p_sys->psz_header = psz_header; } } @@ -1089,7 +1106,7 @@ static int ParseVplayer( demux_t *p_demux, subtitle_t *p_subtitle, p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 + (int64_t)m1 * 60*1000 + (int64_t)s1 * 1000 ) * 1000; - p_subtitle->i_stop = 0; + p_subtitle->i_stop = -1; break; } free( psz_text ); @@ -1204,7 +1221,7 @@ static int ParseSami( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) } p_subtitle->i_start = i_start * 1000; - p_subtitle->i_stop = 0; + p_subtitle->i_stop = -1; p_subtitle->psz_text = strdup( text ); return VLC_SUCCESS; @@ -1252,7 +1269,7 @@ static int ParseDVDSubtitle( demux_t *p_demux, subtitle_t *p_subtitle, (int64_t)m1 * 60*1000 + (int64_t)s1 * 1000 + (int64_t)c1 * 10) * 1000; - p_subtitle->i_stop = 0; + p_subtitle->i_stop = -1; break; } } @@ -1281,7 +1298,7 @@ static int ParseDVDSubtitle( demux_t *p_demux, subtitle_t *p_subtitle, } i_old = strlen( psz_text ); - psz_text = realloc( psz_text, i_old + i_len + 1 + 1 ); + psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 ); if( !psz_text ) return VLC_ENOMEM; strcat( psz_text, s ); @@ -1317,12 +1334,12 @@ static int ParseMPL2( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) return VLC_ENOMEM; i_start = 0; - i_stop = 0; + i_stop = -1; if( sscanf( s, "[%d][] %[^\r\n]", &i_start, psz_text ) == 2 || sscanf( s, "[%d][%d] %[^\r\n]", &i_start, &i_stop, psz_text ) == 3) { p_subtitle->i_start = (int64_t)i_start * 100000; - p_subtitle->i_stop = (int64_t)i_stop * 100000; + p_subtitle->i_stop = i_stop >= 0 ? ((int64_t)i_stop * 100000) : -1; break; } free( psz_text ); @@ -1361,13 +1378,16 @@ static int ParseAQT( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) const char *s = TextGetLine( txt ); if( !s ) + { + free( psz_text ); return VLC_EGENERIC; + } /* Data Lines */ if( sscanf (s, "-->> %d", &t) == 1) { p_subtitle->i_start = (int64_t)t; /* * FPS*/ - p_subtitle->i_stop = 0; + p_subtitle->i_stop = -1; /* Starting of a subtitle */ if( i_firstline ) @@ -1385,7 +1405,7 @@ static int ParseAQT( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) else { i_old = strlen( psz_text ) + 1; - psz_text = realloc( psz_text, i_old + strlen( s ) + 1 ); + psz_text = realloc_or_free( psz_text, i_old + strlen( s ) + 1 ); if( !psz_text ) return VLC_ENOMEM; strcat( psz_text, s ); @@ -1469,7 +1489,10 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) const char *s = TextGetLine( txt ); if( !s ) + { + free( psz_text ); return VLC_EGENERIC; + } if( strstr( s, "FORMAT" ) ) { @@ -1481,7 +1504,10 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) psz_temp = malloc( strlen(s) ); if( !psz_temp ) + { + free( psz_text ); return VLC_ENOMEM; + } if( sscanf( s, "FORMAT=%[^\r\n]", psz_temp ) ) { @@ -1514,7 +1540,10 @@ static int ParseMPSub( 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 ) @@ -1522,7 +1551,7 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) int i_old = strlen( psz_text ); - psz_text = realloc( psz_text, i_old + i_len + 1 + 1 ); + psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 ); if( !psz_text ) return VLC_ENOMEM; @@ -1652,12 +1681,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 ) @@ -1665,13 +1697,13 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) int i_old = strlen( psz_text ); - psz_text = realloc( psz_text, i_old + i_len + 1 ); + psz_text = realloc_or_free( psz_text, i_old + i_len + 1 ); if( !psz_text ) return VLC_ENOMEM; psz_orig = psz_text; strcat( psz_text, s2 ); - } + } /* Skip the blanks */ while( *psz_text == ' ' || *psz_text == '\t' ) psz_text++; @@ -1821,7 +1853,7 @@ static int ParsePSB( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) static int64_t ParseRealTime( char *psz, int *h, int *m, int *s, int *f ) { - if( strlen( psz ) == 0 ) return 0; + if( *psz == '\0' ) return 0; if( sscanf( psz, "%d:%d:%d.%d", h, m, s, f ) == 4 || sscanf( psz, "%d:%d.%d", m, s, f ) == 3 || sscanf( psz, "%d.%d", s, f ) == 2 || @@ -1839,14 +1871,14 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) VLC_UNUSED( i_idx ); demux_sys_t *p_sys = p_demux->p_sys; text_t *txt = &p_sys->txt; - char *psz_text; - char psz_end[12]= "", psz_begin[12] = ""; + char *psz_text = NULL; for( ;; ) { 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 ) return VLC_EGENERIC; @@ -1860,37 +1892,28 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) char *psz_temp = strcasestr( s, "]%[^\n\r]", + "<%*[t|T]ime %*[b|B]egin=\"%11[^\"]\" %*[e|E]nd=\"%11[^\"]%*[^>]%[^\n\r]", psz_begin, psz_end, psz_text) != 3 ) && /* Line has begin and no end */ ( sscanf( psz_temp, - "<%*[t|T]ime %*[b|B]egin=\"%[^\"]\"%*[^>]%[^\n\r]", + "<%*[t|T]ime %*[b|B]egin=\"%11[^\"]\"%*[^>]%[^\n\r]", psz_begin, psz_text ) != 2) ) /* Line is not recognized */ { - free( psz_text ); continue; } /* Get the times */ int64_t i_time = ParseRealTime( psz_begin, &h1, &m1, &s1, &f1 ); - if( i_time >= 0) - { - p_subtitle->i_start = i_time; - } + p_subtitle->i_start = i_time >= 0 ? i_time : 0; i_time = ParseRealTime( psz_end, &h2, &m2, &s2, &f2 ); - if( i_time >= 0 ) - { - p_subtitle->i_stop = i_time; - } + p_subtitle->i_stop = i_time >= 0 ? i_time : -1; break; } - /* Line is not recognized */ - else continue; - free( psz_text ); } /* Get the following Lines */ @@ -1899,7 +1922,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; @@ -1913,7 +1939,7 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) int i_old = strlen( psz_text ); - psz_text = realloc( psz_text, i_old + i_len + 1 + 1 ); + psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 ); if( !psz_text ) return VLC_ENOMEM; @@ -1959,12 +1985,17 @@ static int ParseDKS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) char *s = TextGetLine( txt ); if( !s ) + { + free( psz_text ); return VLC_EGENERIC; + } if( sscanf( s, "[%d:%d:%d]", &h2, &m2, &s2 ) == 3 ) p_subtitle->i_stop = ( (int64_t)h2 * 3600*1000 + (int64_t)m2 * 60*1000 + (int64_t)s2 * 1000 ) * 1000; + else + p_subtitle->i_stop = -1; break; } free( psz_text ); @@ -2015,12 +2046,18 @@ static int ParseSubViewer1( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx s = TextGetLine( txt ); if( !s ) + { + free( psz_text ); return VLC_EGENERIC; + } if( sscanf( s, "[%d:%d:%d]", &h2, &m2, &s2 ) == 3 ) p_subtitle->i_stop = ( (int64_t)h2 * 3600*1000 + (int64_t)m2 * 60*1000 + (int64_t)s2 * 1000 ) * 1000; + else + p_subtitle->i_stop = -1; + break; } }