Fix potential memory leak (free AVFrame instance)

This commit is contained in:
Stephen Seo 2021-12-06 15:24:02 +09:00
parent 926269198e
commit efe6b4ff18

View 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, {}};
}