Commit f5f434a6 authored by Eric Petit's avatar Eric Petit

Fixes bad error checking on read errors.

Don't use "p_block->i_buffer = read(...)", i_buffer is unsigned so you
won't catch read errors and will end up crashing using a 4GB buffer
instead. This fixes a DVB segv I was seeing.
parent 538ec8f8
......@@ -494,13 +494,14 @@ static block_t *Block( access_t *p_access )
{
p_block = block_New( p_access,
p_sys->i_read_once * TS_PACKET_SIZE );
if( ( p_block->i_buffer = read( p_sys->i_handle, p_block->p_buffer,
if( ( i_ret = read( p_sys->i_handle, p_block->p_buffer,
p_sys->i_read_once * TS_PACKET_SIZE ) ) <= 0 )
{
msg_Warn( p_access, "read failed (%m)" );
block_Release( p_block );
continue;
}
p_block->i_buffer = i_ret;
break;
}
}
......
......@@ -285,16 +285,17 @@ static void* Thread( vlc_object_t* p_this )
}
else
{
if( ( p_block = block_New( p_access, 2048 ) ) == NULL ) break;
int i_read;
p_block->i_buffer =
p_src->pf_read( p_src, p_block->p_buffer, 2048 );
if( ( p_block = block_New( p_access, 2048 ) ) == NULL ) break;
if( p_block->i_buffer <= 0 )
i_read = p_src->pf_read( p_src, p_block->p_buffer, 2048 );
if( i_read <= 0 )
{
block_Release( p_block );
p_block = NULL;
}
p_block->i_buffer = i_read;
}
if( p_block == NULL )
......
......@@ -273,16 +273,18 @@ static int Demux( demux_t *p_demux )
block_t *p_frame;
int i_bk = ( p_sys->fmt.audio.i_bitspersample / 8 ) *
p_sys->fmt.audio.i_channels;
int i_read;
p_frame = block_New( p_demux, p_sys->fmt.audio.i_rate / 10 * i_bk );
p_frame->i_buffer = ModPlug_Read( p_sys->f, p_frame->p_buffer, p_frame->i_buffer );
if( p_frame->i_buffer <= 0 )
i_read = ModPlug_Read( p_sys->f, p_frame->p_buffer, p_frame->i_buffer );
if( i_read <= 0 )
{
/* EOF */
block_Release( p_frame );
return 0;
}
p_frame->i_buffer = i_read;
/* Set PCR */
es_out_Control( p_demux->out, ES_OUT_SET_PCR, (int64_t)p_sys->i_time );
......
......@@ -336,7 +336,7 @@ static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
int64_t i_maxdate;
int i;
int i, i_read;
for( i = 0; i < p_sys->i_tracks; i++ )
{
......@@ -382,13 +382,14 @@ static int Demux( demux_t *p_demux )
}
/* read data */
p_block->i_buffer = stream_Read( p_sys->p_vobsub_stream, p_block->p_buffer, i_size );
if( p_block->i_buffer <= 6 )
i_read = stream_Read( p_sys->p_vobsub_stream, p_block->p_buffer, i_size );
if( i_read <= 6 )
{
block_Release( p_block );
tk.i_current_subtitle++;
continue;
}
p_block->i_buffer = i_read;
/* pts */
p_block->i_pts = tk.p_subtitles[tk.i_current_subtitle].i_start;
......
......@@ -2124,9 +2124,10 @@ block_t *stream_Block( stream_t *s, int i_size )
block_t *p_bk = block_New( s, i_size );
if( p_bk )
{
p_bk->i_buffer = stream_Read( s, p_bk->p_buffer, i_size );
if( p_bk->i_buffer > 0 )
int i_read = stream_Read( s, p_bk->p_buffer, i_size );
if( i_read > 0 )
{
p_bk->i_buffer = i_read;
return p_bk;
}
block_Release( p_bk );
......
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