Commit 2b2de58b authored by Ben Hutchings's avatar Ben Hutchings Committed by Rémi Denis-Courmont

live555: handle buffer resize error cases

Do not update buffer size if realloc() fails.

Assert that buffer was not overflowed rather than merely warning.
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 7bb7862b
......@@ -1617,8 +1617,7 @@ static void StreamRead( void *p_private, unsigned int i_size,
void *p_tmp;
msg_Dbg( p_demux, "lost %d bytes", i_truncated_bytes );
msg_Dbg( p_demux, "increasing buffer size to %d", tk->i_buffer * 2 );
tk->i_buffer *= 2;
p_tmp = realloc( tk->p_buffer, tk->i_buffer );
p_tmp = realloc( tk->p_buffer, tk->i_buffer * 2 );
if( p_tmp == NULL )
{
msg_Warn( p_demux, "realloc failed" );
......@@ -1626,13 +1625,12 @@ static void StreamRead( void *p_private, unsigned int i_size,
else
{
tk->p_buffer = (uint8_t*)p_tmp;
tk->i_buffer *= 2;
}
}
if( i_size > tk->i_buffer )
{
msg_Warn( p_demux, "buffer overflow" );
}
/* FIXME could i_size be > buffer size ? */
assert( i_size <= tk->i_buffer );
if( tk->fmt.i_codec == VLC_CODEC_AMR_NB ||
tk->fmt.i_codec == VLC_CODEC_AMR_WB )
{
......
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