[vlc-devel] commit: decomp: handle NULL reads (skipping data) properly - fixes #2409 ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Jan 13 21:59:10 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Tue Jan 13 22:56:48 2009 +0200| [227c679c6aa76d48987352a9d37d8c71eb5ac0f4] | committer: Rémi Denis-Courmont 

decomp: handle NULL reads (skipping data) properly - fixes #2409

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

 modules/stream_filter/decomp.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index 7ec7b51..a3395cf 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -143,6 +143,8 @@ static void *Thread (void *data)
 }
 
 
+static int Peek (stream_t *, const uint8_t **, unsigned int);
+
 #define MIN_BLOCK (1 << 10)
 #define MAX_BLOCK (1 << 20)
 /**
@@ -155,11 +157,17 @@ static int Read (stream_t *stream, void *buf, unsigned int buflen)
     block_t *peeked;
     ssize_t length;
 
+    if (buf == NULL) /* caller skips data, get big enough peek buffer */
+        buflen = Peek (stream, &(const uint8_t *){ NULL }, buflen);
+
     if ((peeked = p_sys->peeked) != NULL)
     {   /* dequeue peeked data */
         length = (buflen > peeked->i_buffer) ? peeked->i_buffer : buflen;
-        memcpy (buf, peeked->p_buffer, length);
-        buf = ((char *)buf) + length;
+        if (buf != NULL)
+        {
+            memcpy (buf, peeked->p_buffer, length);
+            buf = ((char *)buf) + length;
+        }
         buflen -= length;
         peeked->p_buffer += length;
         peeked->i_buffer -= length;




More information about the vlc-devel mailing list