[vlc-commits] avcodec: Fix dereference after NULL check (cid #1048740)

Tristan Matthews git at videolan.org
Wed Jul 16 03:04:26 CEST 2014


vlc | branch: master | Tristan Matthews <le.businessman at gmail.com> | Tue Jul 15 20:52:23 2014 -0400| [4386b8c617c34f79d1b8ec0780e9cffaa9d16ac0] | committer: Tristan Matthews

avcodec: Fix dereference after NULL check (cid #1048740)

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

 modules/codec/avcodec/encoder.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 9b93278..0c4f2e4 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -656,7 +656,8 @@ int OpenEncoder( vlc_object_t *p_this )
 
         /* Try to match avcodec input format to vlc format so we could avoid one
            format conversion */
-        if( GetVlcAudioFormat( p_context->sample_fmt ) != p_enc->fmt_in.i_codec )
+        if( GetVlcAudioFormat( p_context->sample_fmt ) != p_enc->fmt_in.i_codec
+            && p_codec->sample_fmts )
         {
             msg_Dbg( p_enc, "Trying to find more suitable sample format instead of %s", av_get_sample_fmt_name( p_context->sample_fmt ) );
             for( unsigned int i=0; p_codec->sample_fmts[i] != -1; i++ )
@@ -672,7 +673,7 @@ int OpenEncoder( vlc_object_t *p_this )
         p_sys->b_planar = av_sample_fmt_is_planar( p_context->sample_fmt );
         // Try if we can use interleaved format for codec input as VLC doesn't really do planar audio yet
         // FIXME: Remove when planar/interleaved audio in vlc is equally supported
-        if( p_sys->b_planar )
+        if( p_sys->b_planar && p_codec->sample_fmts )
         {
             msg_Dbg( p_enc, "Trying to find packet sample format instead of planar %s", av_get_sample_fmt_name( p_context->sample_fmt ) );
             for( unsigned int i=0; p_codec->sample_fmts[i] != -1; i++ )



More information about the vlc-commits mailing list