[vlc-devel] [PATCH] check NULL pointers

Laurent Aimar fenrir at babylon.via.ecp.fr
Tue Mar 30 20:24:28 CEST 2010


Hi,

On Tue, Mar 30, 2010 at 02:08:37PM -0300, Lucas C. Villa Real wrote:
> 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.
 Could you share a sample ?

> @@ -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 )
 I don't see how it is possible for EsOutProgramGetMetaName to be called
with a NULL p_pgrm. If it is, then it means there is a bug elsewhere that
should be addressed instead of being workarounded here.

>      /* */
> -    char **ppsz_all_keys = vlc_meta_CopyExtraNames(p_meta );
> -
> +    char **ppsz_all_keys = p_meta ? vlc_meta_CopyExtraNames( p_meta ) : NULL;
> +
 Same here, EsOutProgramMeta cannot be called with a NULL p_meta.

>      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] ) )
ppsz_all_keys cannot be NULL, vlc_meta_CopyExtraNames will segfault
if no more memory...
 The test *ppsz_all_keys (probably more consitant if ppsz_all_keys[0] were
used) seems to fix a real bug to me. Could you resend that in a patch ?

> -    free( ppsz_all_keys );
> +    if( ppsz_all_keys )
> +           free( ppsz_all_keys );
free(NULL) is accepted in VLC, so it is not needed.

Regards,

-- 
fenrir



More information about the vlc-devel mailing list