From efe6b4ff18268a975f882b7b44a878fbcedde4b8 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 6 Dec 2021 15:24:02 +0900 Subject: [PATCH] Fix potential memory leak (free AVFrame instance) --- src/video.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video.cc b/src/video.cc index 01addf1..bac0b91 100644 --- a/src/video.cc +++ b/src/video.cc @@ -474,6 +474,9 @@ std::tuple> Video::HandleDecodingPacket( } if (output_as_pngs) { + // free temp_frame as it will not be used on this branch + av_frame_free(&temp_frame); + // get png output name padded with zeroes std::string out_name = "output_"; unsigned int tens = 1; for (unsigned int i = 0; i < 9; ++i) { @@ -484,6 +487,7 @@ std::tuple> Video::HandleDecodingPacket( } out_name += std::to_string(frame_count_); out_name += ".png"; + // write png from frame if (!dithered_image->SaveAsPNG(out_name, true)) { return {false, {}}; }