[vlc-devel] commit: (live555) make sure buffer lengths match allocated sizes. ( Jean-Paul Saman )

git version control git at videolan.org
Mon Nov 24 15:06:37 CET 2008


vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Sun Nov 23 16:42:47 2008 +0100| [e5d70696d372b323000f32390ab13c59b711c5b3] | committer: Jean-Paul Saman 

(live555) make sure buffer lengths match allocated sizes.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e5d70696d372b323000f32390ab13c59b711c5b3
---

 modules/demux/live555.cpp |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp
index 76c2931..03286d5 100644
--- a/modules/demux/live555.cpp
+++ b/modules/demux/live555.cpp
@@ -313,6 +313,7 @@ static int  Open ( vlc_object_t *p_this )
 
         for( ;; )
         {
+            uint8_t *p_tmp = NULL;
             int i_read = stream_Read( p_demux->s, &p_sdp[i_sdp],
                                       i_sdp_max - i_sdp - 1 );
 
@@ -337,8 +338,12 @@ static int  Open ( vlc_object_t *p_this )
                 break;
             }
 
-            i_sdp_max += 1000;
-            p_sdp = (uint8_t*)realloc( p_sdp, i_sdp_max );
+            p_tmp = (uint8_t*)realloc( p_sdp, i_sdp_max + 1000 );
+            if( p_tmp )
+            {
+                p_sdp = p_tmp;
+                i_sdp_max += 1000;
+            }
         }
         p_sys->p_sdp = (char*)p_sdp;
     }
@@ -1544,8 +1549,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" );
@@ -1553,6 +1557,7 @@ 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 )




More information about the vlc-devel mailing list