[FFmpeg-devel] [PATCH V1] lavf/matroskaenc: Fix memory leak after write trailer
mypopy at gmail.com
mypopy at gmail.com
Thu Apr 4 12:52:49 EEST 2019
On Thu, Apr 4, 2019 at 5:43 PM Hendrik Leppkes <h.leppkes at gmail.com> wrote:
>
> On Thu, Apr 4, 2019 at 11:25 AM Jun Zhao <mypopydev at gmail.com> wrote:
> >
> > From: Jun Zhao <barryjzhao at tencent.com>
> >
> > Fix memory leak after write trailer for #7827
> >
> > Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
> > ---
> > libavformat/matroskaenc.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> > index b9f99c4..22ba93a 100644
> > --- a/libavformat/matroskaenc.c
> > +++ b/libavformat/matroskaenc.c
> > @@ -2571,13 +2571,13 @@ static int mkv_write_trailer(AVFormatContext *s)
> > // check if we have an audio packet cached
> > if (mkv->cur_audio_pkt.size > 0) {
> > ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);
> > - av_packet_unref(&mkv->cur_audio_pkt);
> > if (ret < 0) {
> > av_log(s, AV_LOG_ERROR,
> > "Could not write cached audio packet ret:%d\n", ret);
> > return ret;
> > }
> > }
> > + av_packet_unref(&mkv->cur_audio_pkt);
> >
>
> Won't this leak instead when the error path above is triggered?
> Also, whats in the packet if it has a size of 0?
>
I think is mkv_write_packet() with the codec_type ==
AVMEDIA_TYPE_AUDIO in
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/matroskaenc.c#L2537
More information about the ffmpeg-devel
mailing list