Ticket #3876: mc-3876-dir.c-Cleanup-potential-null-pointer-dereference-warning.patch

File mc-3876-dir.c-Cleanup-potential-null-pointer-dereference-warning.patch, 1.2 KB (added by and, 7 years ago)
  • src/filemanager/dir.c

    From f8807a4216ede625447f348f566d10aa69eaa2ed Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Thu, 4 Jan 2018 07:50:44 +0000
    Subject: [PATCH] (dir.c) Cleanup potential null pointer dereference warning
    
    Found by GCC 7.2.0.
    
    dir.c:653:31: warning: potential null pointer dereference [-Wnull-dereference]
         if (IS_PATH_SEP (vpath_str[0]) && vpath_str[1] == '\0')
    ../../lib/global.h:132:26: note: in definition of macro 'IS_PATH_SEP'
     #define IS_PATH_SEP(c) ((c) == PATH_SEP)
                              ^
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/filemanager/dir.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c
    index 2482c8625..62b826ab2 100644
    a b dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort, 
    650650 
    651651    vpath_str = vfs_path_as_str (vpath); 
    652652    /* Do not add a ".." entry to the root directory */ 
    653     if (IS_PATH_SEP (vpath_str[0]) && vpath_str[1] == '\0') 
     653    if (vpath_str != NULL && IS_PATH_SEP (vpath_str[0]) && vpath_str[1] == '\0') 
    654654        dir_list_clean (list); 
    655655 
    656656    while ((dp = mc_readdir (dirp)) != NULL)