[FFmpeg-devel] [PATCH] Allow mpjpeg demuxer to process MIME parts which do not include Content-Length header.

Alexander Agranovsky alex at sighthound.com
Mon Nov 30 02:09:15 CET 2015



On 11/29/15 1:16 PM, Nicolas George wrote:
> Le nonidi 9 frimaire, an CCXXIV, Ganesh Ajjanagadde a écrit :
>>>>       end = p + strlen(p) - 1;
>> Don't know what you are referring to here, but dereferencing is
>> clearly invalid. However, in order to allow common loop idioms,
>> pointer arithmetic one element beyond a array (memory) range is valid:
> Of course. But one element BEFORE the beginning of an array is invalid. In
> other words p + sizeof(p) is valid (assuming p is char[]), but p - 1 is not.
>
> In this instance, if p is a 0-terminated string, p + strlen(p) is always
> valid, even without the provision you mention, because the 0 is part of the
> object. But p + strlen(p) - 1 is not, if strlen(p) can be 0.
>
> Note that dereferencing or not is not relevant: some architectures have
> special registers for pointers that would cause traps just loading an
> invalid pointer (think: p at offset 0 of segment S, p-1 at offset max of
> segment S-1 -> load segment descriptor). FFmpeg probably does not run on any
> such architecture, though. But still, this is bad style.
>
> Regards,
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Ended up reworking these few lines to operate on indices, rather than 
doing pointer airthmetics. Should be the same thing, functionally.


More information about the ffmpeg-devel mailing list