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

Frederic YHUEL fyhuel at viotech.net
Wed Jan 4 14:02:15 CET 2012


>>>>
>>>> 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.
>>>
>
> So what is the right thing to do? Do you agree that currently data is
> read (instead of being skipped) when p_read is null?
>

I mean, what's the point to allocate a buffer and memcpy data in it,
if the caller just wants to skips that data?

Ok it will not hinder perf a lot, but it makes code harder to understand.

Or am I missing something?

-- 
Frédéric



More information about the vlc-devel mailing list