vlc | branch: master | Luca Barbato <lu_z...@gentoo.org> | Wed Oct 23 11:42:57 
2013 +0200| [c7713c7cc608b978dd2e9cc1c20cc4b18029659e] | 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 <j...@videolan.org>

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

 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 3098ab9..51fe558 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -790,8 +790,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;
 
@@ -828,7 +829,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,

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to