Skip to content

Commit

Permalink
avformat/segafilmenc: Add deinit function
Browse files Browse the repository at this point in the history
Prevents memleaks when the trailer is never written or when shifting the
data fails when writing the trailer.

Signed-off-by: Andreas Rheinhardt <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
mkver authored and michaelni committed Feb 25, 2020
1 parent ab44f0a commit da304e7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libavformat/segafilmenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,23 @@ static int film_write_header(AVFormatContext *format_context)
packet = packet->next;
av_freep(&prev);
}
film->start = film->last = NULL;

return 0;
}

static void film_deinit(AVFormatContext *format_context)
{
FILMOutputContext *film = format_context->priv_data;
FILMPacket *packet = film->start;
while (packet != NULL) {
FILMPacket *next = packet->next;
av_free(packet);
packet = next;
}
film->start = film->last = NULL;
}

AVOutputFormat ff_segafilm_muxer = {
.name = "film_cpk",
.long_name = NULL_IF_CONFIG_SMALL("Sega FILM / CPK"),
Expand All @@ -374,4 +387,5 @@ AVOutputFormat ff_segafilm_muxer = {
.init = film_init,
.write_trailer = film_write_header,
.write_packet = film_write_packet,
.deinit = film_deinit,
};

0 comments on commit da304e7

Please sign in to comment.