[FFmpeg-cvslog] avformat/mp3enc: use av_copy_packet()

Michael Niedermayer git at videolan.org
Wed Jun 25 17:01:24 CEST 2014


ffmpeg | branch: release/2.0 | Michael Niedermayer <michaelni at gmx.at> | Sat Mar 22 01:26:48 2014 +0100| [673f679c8ae219b6857600f6e3a2d399f6742d80] | committer: Michael Niedermayer

avformat/mp3enc: use av_copy_packet()

Fixes double free
Fixes Ticket3476

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit d003a0cd2e587a47627fd328f9fc5a484adc29f2)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=673f679c8ae219b6857600f6e3a2d399f6742d80
---

 libavformat/mp3enc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index ee0956e..c94aa59 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -418,14 +418,14 @@ 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)
                 return AVERROR(ENOMEM);
 
-            pktl->pkt     = *pkt;
-            pktl->pkt.buf = av_buffer_ref(pkt->buf);
-            if (!pktl->pkt.buf) {
+            ret = av_copy_packet(&pktl->pkt, pkt);
+            if (ret < 0) {
                 av_freep(&pktl);
-                return AVERROR(ENOMEM);
+                return ret;
             }
 
             if (mp3->queue_end)



More information about the ffmpeg-cvslog mailing list