[vlc-commits] avcodec: Always use av_malloc to alloc extradata

Luca Barbato git at videolan.org
Wed Oct 23 11:49:31 CEST 2013


vlc/vlc-2.1 | branch: master | Luca Barbato <lu_zero at gentoo.org> | Wed Oct 23 11:42:57 2013 +0200| [2f5e94156baa8055b05df5e5600ee91c3582859d] | committer: Jean-Baptiste Kempf

avcodec: Always use av_malloc to alloc extradata

And always pad it while at it.
Codecs always expect extradata to be aligned and padded.

Prevent memory corruption when memalign-hack is enabled.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit c7713c7cc608b978dd2e9cc1c20cc4b18029659e)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=2f5e94156baa8055b05df5e5600ee91c3582859d
---

 modules/codec/avcodec/video.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index a4b6490..f0e69ec 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -814,8 +814,9 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
         uint8_t *p;
 
         p_sys->p_context->extradata_size = i_size + 12;
-        p = p_sys->p_context->extradata  =
-            malloc( p_sys->p_context->extradata_size );
+        p = p_sys->p_context->extradata =
+            av_malloc( p_sys->p_context->extradata_size +
+                       FF_INPUT_BUFFER_PADDING_SIZE );
         if( !p )
             return;
 
@@ -852,7 +853,7 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
     {
         p_sys->p_context->extradata_size = i_size;
         p_sys->p_context->extradata =
-            malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
+            av_malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
         if( p_sys->p_context->extradata )
         {
             memcpy( p_sys->p_context->extradata,



More information about the vlc-commits mailing list