]> git.sesse.net Git - vlc/commitdiff
Fix a segfault : check the return value of x264_encoder_open().
authorAdrien Maglo <magsoft@videolan.org>
Thu, 28 May 2009 18:05:23 +0000 (20:05 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 29 May 2009 22:32:43 +0000 (00:32 +0200)
According to x264 code, if it fails, it return NULL.
And with a first NULL parameter x264_encoder_headers() segfaults.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit 77dea4efed8f1ce11edf551ac33b53ead9fb16a8)

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/x264.c

index 93df88d8956581ace5c4eca0097f6d7c8d815d0b..25c41437bcf9518061ea5dc88e8d8127999a0c7d 100644 (file)
@@ -1303,6 +1303,12 @@ static int  Open ( vlc_object_t *p_this )
     /* Open the encoder */
     p_sys->h = x264_encoder_open( &p_sys->param );
 
+    if( p_sys->h == NULL )
+    {
+        msg_Err( p_enc, "cannot open x264 encoder" );
+        return VLC_EGENERIC;
+    }
+
     /* alloc mem */
     p_sys->i_buffer = 4 * p_enc->fmt_in.video.i_width *
         p_enc->fmt_in.video.i_height + 1000;