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

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

    From 4a72f11b272e8c30ef2102eda94ba50f8f1728a1 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Wed, 3 Jan 2018 17:22:59 +0000
    Subject: [PATCH] (pannel.c) Cleanup potential null pointer dereference warning
    
    Found by GCC 6.4.0.
    
    panel.c: In function 'panel_reload':
    panel.c:4188:40: warning: potential null pointer dereference [-Wnull-dereference]
             if (IS_PATH_SEP (panel_cwd_path[0]) && panel_cwd_path[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/panel.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c
    index a3d88b8a8..c653b821d 100644
    a b panel_recursive_cd_to_parent (const vfs_path_t * vpath) 
    41854185 
    41864186        /* check if path contains only '/' */ 
    41874187        panel_cwd_path = vfs_path_as_str (cwd_vpath); 
    4188         if (IS_PATH_SEP (panel_cwd_path[0]) && panel_cwd_path[1] == '\0') 
     4188        if (panel_cwd_path != NULL && IS_PATH_SEP (panel_cwd_path[0]) && panel_cwd_path[1] == '\0') 
    41894189            return NULL; 
    41904190 
    41914191        tmp_vpath = vfs_path_vtokens_get (cwd_vpath, 0, -1);