From 17e2e9acd9b9be3cc3637a60507892ca4a97bd0a Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 30 Apr 2014 15:30:45 +0100 Subject: [PATCH] avaudenc: avoid using wrong number of samples If audio_in is NULL, we'll send a NULL frame to libav, to flush the codec. In that case, we won't know how many samples the codec will have used, so we use -1 (for don't know) when letting the base class know about the buffer. Coverity 1195177 --- ext/libav/gstavaudenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/libav/gstavaudenc.c b/ext/libav/gstavaudenc.c index fcb176dc9f..a9aa88ad35 100644 --- a/ext/libav/gstavaudenc.c +++ b/ext/libav/gstavaudenc.c @@ -553,7 +553,7 @@ gst_ffmpegaudenc_encode_audio (GstFFMpegAudEnc * ffmpegaudenc, pkt, gst_ffmpegaudenc_free_avpacket); codec = ffmpegaudenc->context->codec; - if ((codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) { + if ((codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) || !audio_in) { ret = gst_audio_encoder_finish_frame (enc, outbuf, -1); } else { ret = gst_audio_encoder_finish_frame (enc, outbuf, frame.nb_samples);