Commit e2fb1043 authored by Filip Roséen's avatar Filip Roséen Committed by Thomas Guillem

demux/asf: fix 17601: fix undesired integer underflow

This commit shall be viewed as a fix-up of 86835f9f.

The previous commit in question did not take into account that the
left-hand side expression can of course result in a negative value,
meaning that the value-promotion necessary for the comparison to take
place would result in a very large value (where we expect a very small
one).

fixes #17601
Signed-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent 793c499f
......@@ -212,8 +212,9 @@ static int Demux( demux_t *p_demux )
tk->b_selected = false;
}
while( !p_sys->b_eos && ( ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
UINT64_C( 1000 ) < p_sys->p_fp->i_preroll ) )
while( !p_sys->b_eos && ( p_sys->i_sendtime - p_sys->i_time - CHUNK < 0 ||
( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
UINT64_C( 1000 ) < p_sys->p_fp->i_preroll ) )
{
/* Read and demux a packet */
if( DemuxASFPacket( &p_sys->packet_sys,
......@@ -240,8 +241,9 @@ static int Demux( demux_t *p_demux )
p_sys->i_time = p_sys->i_sendtime;
}
if( p_sys->b_eos || ( ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
UINT64_C( 1000 ) >= p_sys->p_fp->i_preroll ) )
if( !p_sys->b_eos && ( p_sys->i_sendtime - p_sys->i_time - CHUNK >= 0 &&
( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
UINT64_C( 1000 ) >= p_sys->p_fp->i_preroll ) )
{
bool b_data = Block_Dequeue( p_demux, p_sys->i_time + CHUNK );
......
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