[vlc-devel] [PATCH 1/3] live555: handle buffer resize error cases
Ben Hutchings
ben at decadent.org.uk
Sun May 24 16:12:50 CEST 2009
Do not update buffer size if realloc() fails.
Assert that buffer was not overflowed rather than merely warning.
---
modules/demux/live555.cpp | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp
index aa6a789..3a75409 100644
--- a/modules/demux/live555.cpp
+++ b/modules/demux/live555.cpp
@@ -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 )
{
--
1.6.3.1
More information about the vlc-devel
mailing list