[FFmpeg-devel] [PATCH V2] lavf/matroskaenc: Fix memory leak after write trailer
Jun Zhao
mypopydev at gmail.com
Thu Apr 4 19:08:53 EEST 2019
From: Jun Zhao <barryjzhao at tencent.com>
Fix memory leak after write trailer for #7827, only store a audio
packet whose buffer has size greater than zero in cur_audio_pkt.
Thanks to Andreas Rheinhardt for the suggestions.
Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
---
libavformat/matroskaenc.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index b9f99c4..06f3aeb 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2534,7 +2534,8 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
// buffer an audio packet to ensure the packet containing the video
// keyframe's timecode is contained in the same cluster for WebM
if (codec_type == AVMEDIA_TYPE_AUDIO) {
- ret = av_packet_ref(&mkv->cur_audio_pkt, pkt);
+ if (pkt->size > 0)
+ ret = av_packet_ref(&mkv->cur_audio_pkt, pkt);
} else
ret = mkv_write_packet_internal(s, pkt, 0);
return ret;
--
1.7.1
More information about the ffmpeg-devel
mailing list