[FFmpeg-cvslog] avutil/frame: Use av_memdup() for duplicating extended data array
Andreas Rheinhardt
git at videolan.org
Fri Jun 6 18:31:12 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Jun 3 16:52:49 2025 +0200| [2f5f2c013ceccde74a33d29c071406520634b3a1] | committer: Andreas Rheinhardt
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f5f2c013ceccde74a33d29c071406520634b3a1
---
libavutil/frame.c | 5 ++---
1 file 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;
More information about the ffmpeg-cvslog
mailing list