[vlc-devel] [PATCH] check NULL pointers

Lucas C. Villa Real lucasvr at gobolinux.org
Tue Mar 30 19:08:37 CEST 2010


Hello!

While working with the GIT snapshot I realized that some transport
streams carrying high profile H.264 streams were causing VLC to crash.
A quick investigation pointed the cause to be NULL pointer exceptions.
Please consider merging the patch below.

Thanks,
Lucas


Prevents VLC from accessing NULL pointers when there are no extra
names in p_meta.
Signed-off-by: Lucas C. Villa Real <lucasvr at lsi.usp.br>

diff --git a/src/input/es_out.c b/src/input/es_out.c
index bbcbcd7..f1f738b 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1151,7 +1151,9 @@ static es_out_pgrm_t *EsOutProgramFind( es_out_t
*p_out, int i_group )
 static char *EsOutProgramGetMetaName( es_out_pgrm_t *p_pgrm )
 {
     char *psz = NULL;
-    if( p_pgrm->psz_name )
+    if( ! p_pgrm )
+       return NULL;
+    else if( p_pgrm->psz_name )
     {
         if( asprintf( &psz, _("%s [%s %d]"), p_pgrm->psz_name,
_("Program"), p_pgrm->i_id ) == -1 )
             return NULL;
@@ -1231,10 +1233,10 @@ static void EsOutProgramMeta( es_out_t *out,
int i_group, const vlc_meta_t *p_me
     }

     /* */
-    char **ppsz_all_keys = vlc_meta_CopyExtraNames(p_meta );
-
+    char **ppsz_all_keys = p_meta ? vlc_meta_CopyExtraNames( p_meta ) : NULL;
+
     info_category_t *p_cat = NULL;
-    if( psz_provider || *ppsz_all_keys[0] )
+    if( psz_provider || ( ppsz_all_keys && *ppsz_all_keys &&
*ppsz_all_keys[0] ) )
     {
         char *psz_cat = EsOutProgramGetMetaName( p_pgrm );
         if( psz_cat )
@@ -1242,14 +1244,15 @@ static void EsOutProgramMeta( es_out_t *out,
int i_group, const vlc_meta_t *p_me
         free( psz_cat );
     }

-    for( i = 0; ppsz_all_keys[i]; i++ )
+    for( i = 0; ppsz_all_keys && ppsz_all_keys[i]; i++ )
     {
         if( p_cat )
             info_category_AddInfo( p_cat, vlc_gettext(ppsz_all_keys[i]), "%s",
                                    vlc_meta_GetExtra( p_meta,
ppsz_all_keys[i] ) );
         free( ppsz_all_keys[i] );
     }
-    free( ppsz_all_keys );
+    if( ppsz_all_keys )
+           free( ppsz_all_keys );

     if( psz_provider )
     {



More information about the vlc-devel mailing list