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

Frédéric Yhuel fyhuel at viotech.net
Sat Dec 31 11:43:05 CET 2011


This patch is indeed wrong... I'll send a new one and I will properly test it!

Sorry I lost your time...

(and sorry for top posting)

--
Frédéric


Le 31 déc. 2011 à 10:32, Jean-Paul Saman <jpsaman at videolan.org> a écrit :

> This patch is wrong p_read should have been checked earlier.
> 
> On Fri, Dec 30, 2011 at 11:18 AM,  <fyhuel at viotech.net> wrote:
>> 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);
> 
> Below you update the segment data buffer while p_read is NULL, which
> is the wrong thing to do.
> 
>>             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
>> 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> http://mailman.videolan.org/listinfo/vlc-devel
> 
> Kind regards,
> 
> Jean-Paul Saman
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list