[FFmpeg-cvslog] avutil/frame: Treat frame as uninitialized in get_frame_defaults()
Andreas Rheinhardt
git at videolan.org
Sun Dec 5 19:00:16 EET 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Dec 3 21:19:04 2021 +0100| [6c57e0b4a8825de01e363bc6a6ab598aaf4188e4] | committer: Andreas Rheinhardt
avutil/frame: Treat frame as uninitialized in get_frame_defaults()
Currently, it also tests whether extended_data points to something
different than the AVFrame's data array and frees extended_data
if it is different. Yet this is only necessary for one of its three
callers, namely av_frame_unref(); meanwhile the other two callers
took measures to avoid this (or rather, to make it to an av_free(NULL)).
This commit moves this chunk to av_frame_unref() (so that
get_frame_defaults() now treats its input as uninitialized)
and removes the now superfluous code in the other two callers.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c57e0b4a8825de01e363bc6a6ab598aaf4188e4
---
libavutil/frame.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 64eed5b0dd..0912ad9131 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -52,9 +52,6 @@ const char *av_get_colorspace_name(enum AVColorSpace val)
#endif
static void get_frame_defaults(AVFrame *frame)
{
- if (frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
-
memset(frame, 0, sizeof(*frame));
frame->pts =
@@ -99,12 +96,11 @@ static void wipe_side_data(AVFrame *frame)
AVFrame *av_frame_alloc(void)
{
- AVFrame *frame = av_mallocz(sizeof(*frame));
+ AVFrame *frame = av_malloc(sizeof(*frame));
if (!frame)
return NULL;
- frame->extended_data = NULL;
get_frame_defaults(frame);
return frame;
@@ -457,6 +453,9 @@ void av_frame_unref(AVFrame *frame)
av_buffer_unref(&frame->opaque_ref);
av_buffer_unref(&frame->private_ref);
+ if (frame->extended_data != frame->data)
+ av_freep(&frame->extended_data);
+
get_frame_defaults(frame);
}
@@ -468,7 +467,6 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src)
*dst = *src;
if (src->extended_data == src->data)
dst->extended_data = dst->data;
- memset(src, 0, sizeof(*src));
get_frame_defaults(src);
}
More information about the ffmpeg-cvslog
mailing list