]> git.sesse.net Git - vlc/commitdiff
live555: handle buffer resize error cases
authorBen Hutchings <ben@decadent.org.uk>
Sun, 24 May 2009 14:12:50 +0000 (15:12 +0100)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 24 May 2009 18:10:37 +0000 (21:10 +0300)
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@remlab.net>
modules/demux/live555.cpp

index aa6a789ebaf8411e7a0c6d1af3e2ce80c00dd182..3a754097bfef75c4ce96941a8998abe53582a087 100644 (file)
@@ -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 )
     {