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

Jean-Baptiste Kempf git at videolan.org
Thu Nov 7 18:29:52 CET 2013


vlc/vlc-2.1 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Nov  7 18:12:57 2013 +0100| [a1eed336869a3d76c69fd66ca0819eef2b579f30] | committer: Jean-Baptiste Kempf

avcodec: Always use av_malloc to alloc extradata

This reverts completes 2f5e94156baa8055b05df5e5600ee91c3582859d that was
only partial.

Sorry for the issue.

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

 modules/codec/avcodec/audio.c   |    4 ++--
 modules/codec/avcodec/avcodec.c |    2 +-
 modules/codec/avcodec/video.c   |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 571bf5d..f0d41e0 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -97,7 +97,7 @@ static void InitDecoderConfig( decoder_t *p_dec, AVCodecContext *p_context )
         if( i_size > 0 )
         {
             p_context->extradata =
-                malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
+                av_malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
             if( p_context->extradata )
             {
                 uint8_t *p_dst = p_context->extradata;
@@ -149,7 +149,7 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
     if( ffmpeg_OpenCodec( p_dec ) < 0 )
     {
         msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
-        free( p_sys->p_context->extradata );
+        av_free( p_sys->p_context->extradata );
         free( p_sys );
         return VLC_EGENERIC;
     }
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 04ade54..753a24e 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -362,7 +362,7 @@ static void CloseDecoder( vlc_object_t *p_this )
 
     if( p_sys->p_context )
     {
-        free( p_sys->p_context->extradata );
+        av_free( p_sys->p_context->extradata );
         p_sys->p_context->extradata = NULL;
 
         if( !p_sys->b_delayed_open )
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index f0e69ec..2fd48af 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -858,7 +858,7 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
         {
             memcpy( p_sys->p_context->extradata,
                     p_dec->fmt_in.p_extra, i_size );
-            memset( &((uint8_t*)p_sys->p_context->extradata)[i_size],
+            memset( p_sys->p_context->extradata + i_size,
                     0, FF_INPUT_BUFFER_PADDING_SIZE );
         }
     }



More information about the vlc-commits mailing list