diff mbox series

[FFmpeg-devel,5/5] avcodec/qsvenc: Ensure payload array is initialized when using enc_ctrl

Message ID DM8P223MB0365381F5D43A954CD8455DFBA669@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/mpeg12dec: make mpeg_decode_user_data() accessible
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Soft Works Nov. 29, 2021, 6:51 p.m. UTC
Signed-off-by: softworkz <softworkz@hotmail.com>
---
 libavcodec/qsvenc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 06f55604b5..2c3b22e5f7 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1477,7 +1477,16 @@  static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
     }
 #endif
 
-    if (q->set_encode_ctrl_cb) {
+    if (q->set_encode_ctrl_cb && qsv_frame) {
+
+        if (!qsv_frame->enc_ctrl.Payload) {
+            qsv_frame->enc_ctrl.Payload = av_mallocz(sizeof(mfxPayload*) * QSV_MAX_ENC_PAYLOAD);
+            if (!qsv_frame->enc_ctrl.Payload) {
+                av_freep(&frame);
+                return AVERROR(ENOMEM);
+            }
+        }
+
         q->set_encode_ctrl_cb(avctx, frame, &qsv_frame->enc_ctrl);
     }