diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-06-03 16:52:49 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-06-06 16:27:12 +0200 |
commit | 2f5f2c013ceccde74a33d29c071406520634b3a1 (patch) | |
tree | 8142993d90799b992bae05590c27b4cdd1313b49 /libavutil/frame.c | |
parent | abebdb1bdb737f92edc88aaea71395649a85e37c (diff) | |
download | ffmpeg-2f5f2c013ceccde74a33d29c071406520634b3a1.tar.gz |
avutil/frame: Use av_memdup() for duplicating extended data array
Just do it like av_frame_replace().
Also "fixes" the swapped order or arguments to av_malloc_array()
(the first is supposed to be the number of elements, the second
the size of an element) and therefore part of ticket #11620.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil/frame.c')
-rw-r--r-- | libavutil/frame.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c index 569059c45c..13141f143e 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -348,17 +348,16 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) if (src->extended_data != src->data) { int ch = dst->ch_layout.nb_channels; - if (!ch) { + if (ch <= 0 || ch > SIZE_MAX / sizeof(*dst->extended_data)) { ret = AVERROR(EINVAL); goto fail; } - dst->extended_data = av_malloc_array(sizeof(*dst->extended_data), ch); + dst->extended_data = av_memdup(src->extended_data, sizeof(*dst->extended_data) * ch); if (!dst->extended_data) { ret = AVERROR(ENOMEM); goto fail; } - memcpy(dst->extended_data, src->extended_data, sizeof(*src->extended_data) * ch); } else dst->extended_data = dst->data; |