[FFmpeg-devel] [PATCH] Allow mpjpeg demuxer to process MIME parts which do not include Content-Length header.
Nicolas George
george at nsup.org
Sun Nov 29 19:16:47 CET 2015
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,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151129/e7617fc0/attachment.sig>
More information about the ffmpeg-devel
mailing list