Delete image if image_index == -1

This commit is contained in:
Isaac Connor 2020-12-27 12:00:45 -05:00
parent 197f9bdd9e
commit 3f2d088f8c
1 changed files with 6 additions and 0 deletions

View File

@ -76,6 +76,10 @@ ZMPacket::~ZMPacket() {
analysis_image = nullptr;
}
// We assume the image was allocated elsewhere, so we just unref it.
if ( image_index == -1 ) {
delete image;
delete timestamp;
}
image = nullptr;
timestamp = nullptr;
}
@ -148,6 +152,8 @@ int ZMPacket::decode(AVCodecContext *ctx) {
if ( ret < 0 ) {
Error("Unable to receive frame: %s", av_make_error_string(ret).c_str());
av_frame_free(&in_frame);
Error("Unable to receive frame: %s %p", av_make_error_string(ret).c_str(), in_frame);
return 0;
}