[FFmpeg-cvslog] avutil/frame: Always return error upon error

Andreas Rheinhardt git at videolan.org
Fri Jun 6 18:31:10 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Jun  3 16:44:08 2025 +0200| [abebdb1bdb737f92edc88aaea71395649a85e37c] | committer: Andreas Rheinhardt

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 at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=abebdb1bdb737f92edc88aaea71395649a85e37c
---

 libavutil/frame.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index dcfc835626..569059c45c 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -456,14 +456,11 @@ int av_frame_replace(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;
         }
 
-        if (ch > SIZE_MAX / sizeof(*dst->extended_data))
-            goto fail;
-
         dst->extended_data = av_memdup(src->extended_data, sizeof(*dst->extended_data) * ch);
         if (!dst->extended_data) {
             ret = AVERROR(ENOMEM);



More information about the ffmpeg-cvslog mailing list