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

Luca Barbato lu_zero at gentoo.org
Wed Oct 23 11:42:57 CEST 2013


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

Prevent memory corruption when memalign-hack is enabled.
---

h264_qsv does enjoy it a lot.

 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 5ac682f..471a67d 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -773,8 +773,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;

@@ -811,7 +812,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,
--
1.8.3.2




More information about the vlc-devel mailing list