[FFmpeg-cvslog] avcodec/qsvdec: Check av_image_get_buffer_size() for failure

Michael Niedermayer git at videolan.org
Thu Jun 13 23:41:00 EEST 2024


ffmpeg | branch: release/5.1 | Michael Niedermayer <michael at niedermayer.cc> | Mon May 13 02:05:56 2024 +0200| [52af506fdb348fac505e1c984225f3b1a8226a7a] | committer: Michael Niedermayer

avcodec/qsvdec: Check av_image_get_buffer_size() for failure

Fixes: CID1477406 Improper use of negative value

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang at intel.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 8789c550faf4587527faf0bd4f6c6c5c64a04ae2)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavcodec/qsvdec.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 5fc5bed4c8..4b2c55c8fd 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -347,9 +347,12 @@ static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q, mfxVide
 
     q->frame_info = param->mfx.FrameInfo;
 
-    if (!avctx->hw_frames_ctx)
-        q->pool = av_buffer_pool_init(av_image_get_buffer_size(avctx->pix_fmt,
-                    FFALIGN(avctx->width, 128), FFALIGN(avctx->height, 64), 1), av_buffer_allocz);
+    if (!avctx->hw_frames_ctx) {
+        ret = av_image_get_buffer_size(avctx->pix_fmt, FFALIGN(avctx->width, 128), FFALIGN(avctx->height, 64), 1);
+        if (ret < 0)
+            return ret;
+        q->pool = av_buffer_pool_init(ret, av_buffer_allocz);
+    }
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list