diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-12-03 23:19:04 +0300 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-12-05 15:27:38 +0300 |
commit | 6c57e0b4a8825de01e363bc6a6ab598aaf4188e4 (patch) | |
tree | 2cee2055bb6ba55034f0df6581fc13ef1f139bf7 /libavutil/frame.c | |
parent | fc01a703dea4fe4f2eff73480958ee6c75aa8c30 (diff) |
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@outlook.com>
Diffstat (limited to 'libavutil/frame.c')
-rw-r--r-- | libavutil/frame.c | 10 |
1 files 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); } |