]> git.sesse.net Git - ffmpeg/commitdiff
ffmpeg: Allocate new buffer for bitstream filter when buffer shifted
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 10 Aug 2012 02:33:42 +0000 (04:33 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 10 Aug 2012 02:36:43 +0000 (04:36 +0200)
fix crash with aac_adtstoasc bitstream filter
Fixes Ticket1441

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

index d1df56c0447e3a202e278eaf8fe523b2f7c97f0b..662e84af66fa73221ae634a4c72e1bdc57f2a0b5 100644 (file)
--- 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;