[vlc-devel] commit: live555: handle buffer resize error cases (Ben Hutchings )
git version control
git at videolan.org
Sun May 24 20:10:47 CEST 2009
vlc | branch: master | Ben Hutchings <ben at decadent.org.uk> | Sun May 24 15:12:50 2009 +0100| [2b2de58b71814a5210f39d8eefbffd19c021270e] | committer: 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: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2b2de58b71814a5210f39d8eefbffd19c021270e
---
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 )
{
More information about the vlc-devel
mailing list