[vlc-devel] commit: Fix NULL dereference (unlikely) (CID 112) ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Jun 1 11:10:06 CEST 2008


vlc | branch: 0.8.6-bugfix | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Jun  1 12:07:45 2008 +0300| [3ddc22f2dbc7c143d1b925ab71cf0f47f98c0805]

Fix NULL dereference (unlikely) (CID 112)

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

 modules/codec/subsdec.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c
index edacef5..0bc1655 100644
--- a/modules/codec/subsdec.c
+++ b/modules/codec/subsdec.c
@@ -210,7 +210,9 @@ static int OpenDecoder( vlc_object_t *p_this )
         var_Create( p_dec, "subsdec-encoding",
                     VLC_VAR_STRING | VLC_VAR_DOINHERIT );
         var_Get( p_dec, "subsdec-encoding", &val );
-        if( !strcmp( val.psz_string, DEFAULT_NAME ) )
+        if( !val.psz_string || !*val.psz_string )
+           (void)0;
+        else if( !strcmp( val.psz_string, DEFAULT_NAME ) )
         {
             const char *psz_charset = GetFallbackEncoding();
 
@@ -218,22 +220,24 @@ static int OpenDecoder( vlc_object_t *p_this )
                     "subsdec-autodetect-utf8" );
 
             p_sys->iconv_handle = vlc_iconv_open( "UTF-8", psz_charset );
-            msg_Dbg( p_dec, "using fallback character encoding: %s", psz_charset );
+            msg_Dbg( p_dec, "using fallback character encoding: %s",
+                     psz_charset );
         }
         else if( !strcmp( val.psz_string, "UTF-8" ) )
         {
             msg_Dbg( p_dec, "using enforced character encoding: UTF-8" );
         }
-        else if( val.psz_string )
+        else
         {
-            msg_Dbg( p_dec, "using enforced character encoding: %s", val.psz_string );
+            msg_Dbg( p_dec, "using enforced character encoding: %s",
+                     val.psz_string );
             p_sys->iconv_handle = vlc_iconv_open( "UTF-8", val.psz_string );
             if( p_sys->iconv_handle == (vlc_iconv_t)-1 )
             {
                 msg_Warn( p_dec, "unable to do requested conversion" );
             }
         }
-        if( val.psz_string ) free( val.psz_string );
+        free( val.psz_string );
     }
 
     var_Create( p_dec, "subsdec-align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );




More information about the vlc-devel mailing list