diff options
author | James Almer <jamrial@gmail.com> | 2017-10-06 15:55:09 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-10-06 21:59:11 -0300 |
commit | cc5b7601f7c2d42b1c874a93277915cfb8c41038 (patch) | |
tree | b6b6d3e28b7e28eb4a70f9b1ed0cf630c9b54040 /libavformat/mp3enc.c | |
parent | 2a31ad7d60632cca0f43986b6a5b135848088b14 (diff) | |
download | ffmpeg-cc5b7601f7c2d42b1c874a93277915cfb8c41038.tar.gz |
avformat/mp3enc: flush buffered packets if referencing fails
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/mp3enc.c')
-rw-r--r-- | libavformat/mp3enc.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 826878eca1..8479e2485b 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -515,20 +515,15 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt) if (mp3->pics_to_write) { /* buffer audio packets until we get all the pictures */ AVPacketList *pktl = av_mallocz(sizeof(*pktl)); - int ret; - if (!pktl) { + + if (!pktl || av_packet_ref(&pktl->pkt, pkt) < 0) { + av_freep(&pktl); av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n"); mp3->pics_to_write = 0; mp3_queue_flush(s); return mp3_write_audio_packet(s, pkt); } - ret = av_packet_ref(&pktl->pkt, pkt); - if (ret < 0) { - av_freep(&pktl); - return ret; - } - if (mp3->queue_end) mp3->queue_end->next = pktl; else |