Commit 28ad4a41 authored by Laurent Aimar's avatar Laurent Aimar

* sub.c: fixed handling for subrip subtitle with \r\n instead of \n and

added some sanity checks.
parent ec6e7418
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sub.c * sub.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: sub.c,v 1.1 2002/11/15 18:10:26 fenrir Exp $ * $Id: sub.c,v 1.2 2003/01/21 16:46:17 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -533,7 +533,7 @@ static int sub_MicroDvdRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_mi ...@@ -533,7 +533,7 @@ static int sub_MicroDvdRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_mi
} }
p_subtitle->i_start = (mtime_t)i_start * (mtime_t)i_microsecperframe; p_subtitle->i_start = (mtime_t)i_start * (mtime_t)i_microsecperframe;
p_subtitle->i_stop = (mtime_t)i_stop * (mtime_t)i_microsecperframe; p_subtitle->i_stop = (mtime_t)i_stop * (mtime_t)i_microsecperframe;
p_subtitle->psz_text = strdup( buffer_text ); p_subtitle->psz_text = strndup( buffer_text, MAX_LINE );
return( 0 ); return( 0 );
} }
...@@ -584,9 +584,11 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr ...@@ -584,9 +584,11 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
{ {
return( -1 ); return( -1 );
} }
buffer[MAX_LINE] = '\0'; // just in case
i_len = strlen( buffer ); i_len = strlen( buffer );
if( i_len <= 1 ) // newline if( buffer[0] == '\r' || buffer[0] == '\n' || i_len <= 1 )
{ {
// empty line -> end of this subtitle
buffer_text[__MAX( i_buffer_text - 1, 0 )] = '\0'; buffer_text[__MAX( i_buffer_text - 1, 0 )] = '\0';
p_subtitle->i_start = i_start; p_subtitle->i_start = i_start;
p_subtitle->i_stop = i_stop; p_subtitle->i_stop = i_stop;
...@@ -594,17 +596,21 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr ...@@ -594,17 +596,21 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
return( 0 ); return( 0 );
} }
else else
{
if( i_buffer_text + i_len + 1 < 10 * MAX_LINE )
{ {
memcpy( buffer_text + i_buffer_text, memcpy( buffer_text + i_buffer_text,
buffer, buffer,
i_len ); i_len );
i_buffer_text += i_len; i_buffer_text += i_len;
buffer_text[i_buffer_text] = '\n'; buffer_text[i_buffer_text] = '\n';
i_buffer_text++; i_buffer_text++;
} }
} }
} }
} }
}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment