Commit ca6c02a2 authored by Sam Hocevar's avatar Sam Hocevar

  * Fixed a segfault at EOF in input_es.c and input_ts.c (when i_read == 0).
  * Improved error recovery and avoided memleaks in the various input plugins.
  * Fixed a deadloop inserted by someone else into input_vcd.c :-)
parent 9fb2aad3
......@@ -9,7 +9,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.114 2001/12/29 15:40:53 massiot Exp $
* $Id: input_dvd.c,v 1.115 2001/12/30 04:26:53 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -216,6 +216,7 @@ static void DVDInit( input_thread_t * p_input )
if( dvdcss_seek( p_dvd->dvdhandle, 0, DVDCSS_NOFLAGS ) < 0 )
{
intf_ErrMsg( "dvd error: %s", dvdcss_error( p_dvd->dvdhandle ) );
input_BuffersEnd( p_input->p_method_data );
p_input->b_error = 1;
return;
}
......@@ -229,6 +230,7 @@ static void DVDInit( input_thread_t * p_input )
intf_ErrMsg( "dvd error: allcation error in ifo" );
dvdcss_close( p_dvd->dvdhandle );
free( p_dvd );
input_BuffersEnd( p_input->p_method_data );
p_input->b_error = 1;
return;
}
......@@ -239,6 +241,7 @@ static void DVDInit( input_thread_t * p_input )
IfoDestroy( p_dvd->p_ifo );
dvdcss_close( p_dvd->dvdhandle );
free( p_dvd );
input_BuffersEnd( p_input->p_method_data );
p_input->b_error = 1;
return;
}
......
......@@ -6,7 +6,7 @@
* It depends on: libdvdread for ifo files and block reading.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_dvdread.c,v 1.10 2001/12/29 22:22:01 massiot Exp $
* $Id: input_dvdread.c,v 1.11 2001/12/30 04:26:53 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -203,6 +203,7 @@ static void DvdReadInit( input_thread_t * p_input )
if( (p_input->p_method_data = input_BuffersInit()) == NULL )
{
free( p_dvd );
p_input->b_error = 1;
return;
}
......@@ -216,6 +217,7 @@ static void DvdReadInit( input_thread_t * p_input )
{
intf_ErrMsg( "dvdread error: can't open VMG info" );
DVDClose( p_dvd->p_dvdread );
input_BuffersEnd( p_input->p_method_data );
free( p_dvd );
p_input->b_error = 1;
return;
......
......@@ -2,7 +2,7 @@
* input_es.c: Elementary Stream demux and packet management
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_es.c,v 1.9 2001/12/29 03:07:51 massiot Exp $
* $Id: input_es.c,v 1.10 2001/12/30 04:26:53 sam Exp $
*
* Author: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -222,15 +222,13 @@ static int ESRead( input_thread_t * p_input,
* back to the buffer allocator. */
int i_loop;
for( i_loop = 0; i_loop + 1 < i_read; i_loop++ )
for( i_loop = 0; i_loop < i_read; i_loop++ )
{
p_data = p_data->p_next;
}
p_input->pf_delete_packet( p_input->p_method_data, p_data->p_next );
if( i_read != 0 )
{
p_data->p_next = NULL;
pp_data = &(*pp_data)->p_next;
}
p_input->pf_delete_packet( p_input->p_method_data, *pp_data );
*pp_data = NULL;
}
return( i_read );
......
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ps.c,v 1.9 2001/12/29 03:07:51 massiot Exp $
* $Id: input_ps.c,v 1.10 2001/12/30 04:26:53 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -181,6 +181,7 @@ static void PSInit( input_thread_t * p_input )
if( p_input->p_stream == NULL )
{
intf_ErrMsg( "Cannot open file (%s)", strerror(errno) );
input_BuffersEnd( p_input->p_method_data );
p_input->b_error = 1;
return;
}
......
......@@ -2,7 +2,7 @@
* input_ts.c: TS demux and netlist management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ts.c,v 1.8 2001/12/29 03:07:51 massiot Exp $
* $Id: input_ts.c,v 1.9 2001/12/30 04:26:53 sam Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
......@@ -325,33 +325,22 @@ static int TSRead( input_thread_t * p_input,
i_read /= TS_PACKET_SIZE;
/* Check correct TS header */
for( i_loop = 0; i_loop + 1 < i_read; i_loop++ )
for( i_loop = 0; i_loop < i_read; i_loop++ )
{
if( p_data->p_demux_start[0] != 0x47 )
if( (*pp_data)->p_demux_start[0] != 0x47 )
{
intf_ErrMsg( "input error: bad TS packet (starts with "
"0x%.2x, should be 0x47)",
p_data->p_demux_start[0] );
}
p_data = p_data->p_next;
}
/* Last packet */
if( p_data->p_demux_start[0] != 0x47 )
{
intf_ErrMsg( "input error: bad TS packet (starts with "
"0x%.2x, should be 0x47)",
p_data->p_demux_start[0] );
pp_data = &(*pp_data)->p_next;
}
if( i_read != TS_READ_ONCE )
{
/* Delete remaining packets */
p_input->pf_delete_packet( p_input->p_method_data, p_data->p_next );
if( i_read != 0 )
{
p_data->p_next = NULL;
}
p_input->pf_delete_packet( p_input->p_method_data, *pp_data );
*pp_data = NULL;
}
}
return( i_read );
......
......@@ -241,6 +241,9 @@ static void VCDInit( input_thread_t * p_input )
if ( VCDReadToc( p_vcd ) == -1 )
{
intf_ErrMsg( "vcd error: could not read TOC" );
input_BuffersEnd( p_input->p_method_data );
p_input->b_error = 1;
return;
}
/* Set stream and area data */
......@@ -413,8 +416,7 @@ static int VCDRead( input_thread_t * p_input, data_packet_t ** pp_data )
i_packet = 0;
*pp_data = NULL;
while( i_packet < VCD_DATA_ONCE
&& !p_vcd->b_end_of_track )
while( i_packet < VCD_DATA_ONCE && !p_vcd->b_end_of_track )
{
if ( VCDReadSector( p_vcd, p_buffer ) == -1 )
{
......@@ -436,7 +438,8 @@ static int VCDRead( input_thread_t * p_input, data_packet_t ** pp_data )
/* It is common for MPEG-1 streams to pad with zeros
* (although it is forbidden by the recommendation), so
* don't bother everybody in this case. */
intf_WarnMsg( 3, "vcd warning: garbage at input" );
intf_WarnMsg( 12, "vcd warning: garbage at input" );
break;
}
while( (i_header & 0xFFFFFF00) != 0x100L
......@@ -524,6 +527,8 @@ static int VCDRead( input_thread_t * p_input, data_packet_t ** pp_data )
/* Give the packet to the other input stages. */
*pp_data = p_data;
pp_data = &p_data->p_next;
i_packet++;
}
}
......
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