[vlc-devel] [PATCH 1/2] httplive: fix Read func. (when caller skips data)

fyhuel at viotech.net fyhuel at viotech.net
Fri Dec 30 11:18:20 CET 2011


From: Frédéric Yhuel <fyhuel at viotech.net>

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

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 4d60d8a..58dc1db 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1912,7 +1912,8 @@ static ssize_t hls_Read(stream_t *s, uint8_t *p_read, unsigned int i_read)
 
         if (len > 0)
         {
-            memcpy(p_read + copied, segment->data->p_buffer, len);
+            if( p_read ) /* otherwise caller skips data */
+                memcpy(p_read + copied, segment->data->p_buffer, len);
             segment->data->i_buffer -= len;
             segment->data->p_buffer += len;
             copied += len;
@@ -1935,15 +1936,6 @@ static int Read(stream_t *s, void *buffer, unsigned int i_read)
     if (p_sys->b_error)
         return 0;
 
-    if (buffer == NULL)
-    {
-        /* caller skips data, get big enough buffer */
-        msg_Warn(s, "buffer is NULL (allocate %d)", i_read);
-        buffer = calloc(1, i_read);
-        if (buffer == NULL)
-            return 0; /* NO MEMORY left*/
-    }
-
     length = hls_Read(s, (uint8_t*) buffer, i_read);
     if (length < 0)
         return 0;
-- 
1.7.5.4




More information about the vlc-devel mailing list