[FFmpeg-devel] [PATCH 3/3] wavpackenc: proper buffer allocation

2014-08-19 Thread Christophe Gisquet
The allocation didn't account for headers, that can be easily 79 bytes.
As a result, buffers allocated for a few samples (e.g. 5 in the original
bug) could be undersized.

Fixed ticket #2881.
---
 libavcodec/wavpackenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 46c69a3..3fa2b95 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -2881,10 +2881,11 @@ static int wavpack_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 return AVERROR(ENOMEM);
 }
 
-if ((ret = ff_alloc_packet2(avctx, avpkt, s-block_samples * 
avctx-channels * 8))  0)
+buf_size = s-block_samples * avctx-channels * 8
+ + 200 /* for headers */;
+if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size))  0)
 return ret;
 buf = avpkt-data;
-buf_size = avpkt-size;
 
 for (s-ch_offset = 0; s-ch_offset  avctx-channels;) {
 set_samplerate(s);
-- 
1.9.2.msysgit.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] wavpackenc: proper buffer allocation

2014-08-19 Thread Michael Niedermayer
On Tue, Aug 19, 2014 at 02:50:37PM +0200, Paul B Mahol wrote:
 On 8/19/14, Christophe Gisquet christophe.gisq...@gmail.com wrote:
  The allocation didn't account for headers, that can be easily 79 bytes.
  As a result, buffers allocated for a few samples (e.g. 5 in the original
  bug) could be undersized.
 
  Fixed ticket #2881.
  ---
   libavcodec/wavpackenc.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
 
  diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
  index 46c69a3..3fa2b95 100644
  --- a/libavcodec/wavpackenc.c
  +++ b/libavcodec/wavpackenc.c
  @@ -2881,10 +2881,11 @@ static int wavpack_encode_frame(AVCodecContext
  *avctx, AVPacket *avpkt,
   return AVERROR(ENOMEM);
   }
 
  -if ((ret = ff_alloc_packet2(avctx, avpkt, s-block_samples *
  avctx-channels * 8))  0)
  +buf_size = s-block_samples * avctx-channels * 8
  + + 200 /* for headers */;
  +if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size))  0)
   return ret;
   buf = avpkt-data;
  -buf_size = avpkt-size;
 
   for (s-ch_offset = 0; s-ch_offset  avctx-channels;) {
   set_samplerate(s);
  --
  1.9.2.msysgit.0
 
  ___
  ffmpeg-devel mailing list
  ffmpeg-devel@ffmpeg.org
  http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 
 
 ok
 
 thanks for fixing this bug.

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel