From 980b44bc05edf4ec843321551f02a47e7a8adea1 Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Wed, 13 Nov 2024 00:00:00 +0000 Subject: [PATCH] fix(libvideo2x): added missing checks around freeing memory Signed-off-by: k4yt3x --- src/libvideo2x.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libvideo2x.cpp b/src/libvideo2x.cpp index 812b8ac..555159f 100644 --- a/src/libvideo2x.cpp +++ b/src/libvideo2x.cpp @@ -62,8 +62,14 @@ static int process_frames( // Lambda function for cleaning up resources auto cleanup = [&]() { - av_frame_free(&frame); - av_packet_free(&packet); + if (frame) { + av_frame_free(&frame); + frame = nullptr; + } + if (packet) { + av_packet_free(&packet); + packet = nullptr; + } for (AVFrame *&flushed_frame : flushed_frames) { if (flushed_frame) { av_frame_free(&flushed_frame);