[FFmpeg-devel] [PATCH 1/2] avutil/common: Add FFINCREASE_PTR()

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri Feb 19 23:34:15 EET 2021


Nicolas George:
> Michael Niedermayer (12021-02-19):
>> Suggested-by: Andreas Rheinhardt
>> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
>> ---
>>  doc/APIchanges     | 3 +++
>>  libavutil/common.h | 2 ++
>>  2 files changed, 5 insertions(+)
> 
> Is it only for NULL+0 or is it for all NULL+x?
> 
> It is ok to hide NULL+0, but NULL+x is a different kind of bug, more
> serious, but the macro hides it. Maybe add an av_assert2()?
> 
It is only for NULL+0; NULL+x is a real bug after all.
And the macro doesn't hide it; NULL+x can still be detected with all the
typical tools (ubsan) to detect NULL+x. Doing it this way has the
advantage of allowing the compiler to optimize the branch away (GCC does
it).

- Andreas


More information about the ffmpeg-devel mailing list