[vlc-commits] playlist/art: fix potentiall null-pointer dereference
    Filip Roséen 
    git at videolan.org
       
    Mon Sep  5 18:48:03 CEST 2016
    
    
  
vlc | branch: master | Filip Roséen <filip at atch.se> | Sat Sep  3 14:25:24 2016 +0200| [f7099ec77a7762ae39a252ecadecce56e396fe1d] | committer: Thomas Guillem
playlist/art: fix potentiall null-pointer dereference
filename_sanitize is not callable with a null-pointer, as such we
would potentially dereference such if strdup fails.
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f7099ec77a7762ae39a252ecadecce56e396fe1d
---
 src/playlist/art.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/playlist/art.c b/src/playlist/art.c
index 18a3764..53133e5 100644
--- a/src/playlist/art.c
+++ b/src/playlist/art.c
@@ -139,17 +139,19 @@ end:
 static char *ArtCacheName( input_item_t *p_item, const char *psz_type )
 {
     char *psz_path = ArtCachePath( p_item );
-    if( !psz_path )
-        return NULL;
+    char *psz_ext = strdup( psz_type ? psz_type : "" );
+    char *psz_filename = NULL;
 
-    ArtCacheCreateDir( psz_path );
+    if( unlikely( !psz_path || !psz_ext ) )
+        goto end;
 
-    char *psz_ext = strdup( psz_type ? psz_type : "" );
+    ArtCacheCreateDir( psz_path );
     filename_sanitize( psz_ext );
-    char *psz_filename;
+
     if( asprintf( &psz_filename, "%s" DIR_SEP "art%s", psz_path, psz_ext ) < 0 )
         psz_filename = NULL;
 
+end:
     free( psz_ext );
     free( psz_path );
 
    
    
More information about the vlc-commits
mailing list