1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avutil/frame: Always return error upon error

(I don't know whether this can be triggered for a file with
nonnegative channel count, given that src's extended data can't
have been allocated in this case.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-06-03 16:44:08 +02:00
parent 4bd1ce31fc
commit abebdb1bdb

View File

@ -456,14 +456,11 @@ int av_frame_replace(AVFrame *dst, const AVFrame *src)
if (src->extended_data != src->data) { if (src->extended_data != src->data) {
int ch = dst->ch_layout.nb_channels; int ch = dst->ch_layout.nb_channels;
if (!ch) { if (ch <= 0 || ch > SIZE_MAX / sizeof(*dst->extended_data)) {
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto fail; goto fail;
} }
if (ch > SIZE_MAX / sizeof(*dst->extended_data))
goto fail;
dst->extended_data = av_memdup(src->extended_data, sizeof(*dst->extended_data) * ch); dst->extended_data = av_memdup(src->extended_data, sizeof(*dst->extended_data) * ch);
if (!dst->extended_data) { if (!dst->extended_data) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);