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

Tristan Matthews git at videolan.org
Sat Jul 26 01:19:57 CEST 2014


vlc/vlc-2.2 | branch: master | Tristan Matthews <le.businessman at gmail.com> | Tue Jul 15 20:52:23 2014 -0400| [359eb52a46b47fe209c60bb1947c9955b2288d71] | committer: Jean-Baptiste Kempf

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

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

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

 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 860556f..3e18086 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -660,7 +660,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++ )
@@ -676,7 +677,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