[FFmpeg-cvslog] ffmpeg: Allocate new buffer for bitstream filter when buffer shifted

Michael Niedermayer git at videolan.org
Fri Aug 10 04:44:07 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Aug 10 04:33:42 2012 +0200| [969267482de97b08503d27d2fe090ec820273e40] | committer: Michael Niedermayer

ffmpeg: Allocate new buffer for bitstream filter when buffer shifted

fix crash with aac_adtstoasc bitstream filter
Fixes Ticket1441

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

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

 ffmpeg.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ffmpeg.c b/ffmpeg.c
index d1df56c..662e84a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -534,6 +534,16 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
                                            &new_pkt.data, &new_pkt.size,
                                            pkt->data, pkt->size,
                                            pkt->flags & AV_PKT_FLAG_KEY);
+        if(a == 0 && new_pkt.data != pkt->data && new_pkt.destruct) {
+            uint8_t *t = av_malloc(new_pkt.size + FF_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow
+            if(t) {
+                memcpy(t, new_pkt.data, new_pkt.size);
+                memset(t + new_pkt.size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+                new_pkt.data = t;
+                a = 1;
+            } else
+                a = AVERROR(ENOMEM);
+        }
         if (a > 0) {
             av_free_packet(pkt);
             new_pkt.destruct = av_destruct_packet;



More information about the ffmpeg-cvslog mailing list