]> git.seodisparate.com - EN605.617.81.FA21_StephenSeo_DitheringProject/commitdiff
Fix potential memory leak (free AVFrame instance)
authorStephen Seo <seo.disparate@gmail.com>
Mon, 6 Dec 2021 06:24:02 +0000 (15:24 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 6 Dec 2021 06:24:02 +0000 (15:24 +0900)
src/video.cc

index 01addf15e03433df646a8b1e980ca431f88c64c9..bac0b911915a1da00d8c4ab22ebb06b966dcd301 100644 (file)
@@ -474,6 +474,9 @@ std::tuple<bool, std::vector<AVFrame *>> 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<bool, std::vector<AVFrame *>> 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, {}};
       }