[FFmpeg-cvslog] avcodec/nvenc: fix potential NULL pointer dereference

Zhao Zhili git at videolan.org
Tue Feb 28 20:20:19 EET 2023


ffmpeg | branch: release/6.0 | Zhao Zhili <zhilizhao at tencent.com> | Tue Feb 28 19:12:17 2023 +0100| [0981053c294f8a0edf1a06c329574fb2ebb5d5da] | committer: Timo Rothenpieler

avcodec/nvenc: fix potential NULL pointer dereference

Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>

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

 libavcodec/nvenc.c | 9 +++++++--
 1 file 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);



More information about the ffmpeg-cvslog mailing list