[FFmpeg-devel] [PATCH] avutil/frame: Assert that width/height/channels is 0 for the destination of av_frame*_ref()
Michael Niedermayer
michael at niedermayer.cc
Wed Mar 9 02:56:27 CET 2016
On Tue, Mar 08, 2016 at 10:24:55PM -0300, Gonzalo wrote:
>
>
> El 08/03/16 a las 17:14, Michael Niedermayer escribió:
> >diff --git a/libavutil/frame.c b/libavutil/frame.c
> >index 5607206..dde32b0 100644
> >--- a/libavutil/frame.c
> >+++ b/libavutil/frame.c
> >@@ -375,6 +375,9 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
> > {
> > int i, ret = 0;
> >+ av_assert0(dst->width == 0 && dst->height == 0);
> >+ av_assert0(dst->channels == 0);
> >+
> > dst->format = src->format;
> > dst->width = src->width;
> > dst->height = src->height;
> Why does it matter what dst->width/height is originally? They are
> overwritten right after.
it is to detect if the user calls the functions in the wrong order
which would otherwise trigger memleaks and or undefined behavior
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160309/6104c31a/attachment.sig>
More information about the ffmpeg-devel
mailing list