summaryrefslogtreecommitdiff
path: root/libavcodec/qsv_internal.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-25 12:20:20 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-11-30 17:16:32 +0100
commit1cdbccaa163eb3bd50403ecc75fc3da9d5d75c02 (patch)
tree921adb1a3a6513f03e61d783887c0ef0a2562244 /libavcodec/qsv_internal.h
parente22dff43e72a79bbf559fcc72f5a0f70b77eaff4 (diff)
avcodec/qsvenc: Fix leak and crash when encoding H.264 due to A53_CC
Since commit 3bbe0c210b05fc6fbd7b1d4bbd8479db7f2cf957, the Payloads array of every QSVFrame leaks as soon as the frame is reused; the leak is small and not very noticeable, but if there is an attempt to use said array the ensuing crash is much more noticeable. This happens when encoding H.264 with A53 CC side data. Furthermore, if said array can not be allocated at all, an AVFrame leaks. Fix all of this by not allocating the array separately at all; put it in QSVFrame instead and restore the Payloads array upon reusing the frame. Finally, use av_freep() instead of av_free() to free the payload entries. Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/qsv_internal.h')
-rw-r--r--libavcodec/qsv_internal.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 8090b748b3..fe9d5319c4 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -76,6 +76,8 @@ typedef struct QSVFrame {
mfxExtDecodedFrameInfo dec_info;
mfxExtBuffer *ext_param;
+ mfxPayload *payloads[QSV_MAX_ENC_PAYLOAD]; ///< used for enc_ctrl.Payload
+
int queued;
int used;