roqaudio: Always use the frame buffer on flush
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Nov 2014 10:13:10 +0000 (11:13 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 12 Jan 2015 23:16:40 +0000 (00:16 +0100)
Prevent NULL dereference.

CC: libav-stable@libav.org
Bug-Id: CID 703669
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
(cherry picked from commit 55b59fab880a9fcdd30f97c5170af282087ac4f7)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/roqaudioenc.c

index f97d5d6..402eb78 100644 (file)
@@ -147,15 +147,16 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
             context->input_frames++;
             return 0;
         }
-        in = context->frame_buffer;
     }
+    if (context->input_frames < 8)
+        in = context->frame_buffer;
 
     if (stereo) {
         context->lastSample[0] &= 0xFF00;
         context->lastSample[1] &= 0xFF00;
     }
 
-    if (context->input_frames == 7 || !in)
+    if (context->input_frames == 7)
         data_size = avctx->channels * context->buffered_samples;
     else
         data_size = avctx->channels * avctx->frame_size;