aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2023-02-28 19:12:17 +0100
committerTimo Rothenpieler <timo@rothenpieler.org>2023-02-28 19:16:52 +0100
commit21101d9eb1f26c1f1a58454919a9ef5993ae9900 (patch)
treebc19dc3eb4f9682c87fb12dcd82386eb54cc85b1 /libavcodec/nvenc.c
parent67fd1b79e727d61b71e357dcaddabdf02b0b4c4b (diff)
downloadffmpeg-21101d9eb1f26c1f1a58454919a9ef5993ae9900.tar.gz
avcodec/nvenc: fix potential NULL pointer dereference
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 8a28454042..a8b7a4c0a0 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -178,6 +178,8 @@ static void reorder_queue_flush(AVFifo *queue)
{
FrameData fd;
+ av_assert0(queue);
+
while (av_fifo_read(queue, &fd, 1) >= 0)
av_buffer_unref(&fd.frame_opaque_ref);
}
@@ -1853,8 +1855,11 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx)
p_nvenc->nvEncEncodePicture(ctx->nvencoder, &params);
}
- reorder_queue_flush(ctx->reorder_queue);
- av_fifo_freep2(&ctx->reorder_queue);
+ if (ctx->reorder_queue) {
+ reorder_queue_flush(ctx->reorder_queue);
+ av_fifo_freep2(&ctx->reorder_queue);
+ }
+
av_fifo_freep2(&ctx->output_surface_ready_queue);
av_fifo_freep2(&ctx->output_surface_queue);
av_fifo_freep2(&ctx->unused_surface_queue);