[FFmpeg-devel] [PATCH 17/21] avfilter/formats: Fix double frees and memleaks on error
Nicolas George
george at nsup.org
Sun Aug 23 20:59:23 EEST 2020
Andreas Rheinhardt (12020-08-23):
> > No. If *f is freshly allocated, it has no owner yet and unref_fn(f) will
> > free it and set *f to NULL; av_freep(f) is then a no-op, so I removed
> > it. Keeping it would also be against the philosphy of this API (that it
> > cleans up after itself in case of error).
>
> Actually, no has no option but to remove said code:
> "The value of a pointer becomes indeterminate when the object it points
> to reaches the end of its lifetime." (C99, 6.2.4.2)
>
> If *f doesn't have any owners, it has already been freed in unref_fn()
> and oldf becomes a dangling pointer, so that using it in a check is
> undefined behaviour. (Storing the information whether this is a freshly
> allocated list in a different way (e.g. an int) would of course work,
> but there is no point in doing so.)
Right, thanks for explaining.
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200823/bf785e27/attachment.sig>
More information about the ffmpeg-devel
mailing list