(panel_recursive_cd_to_parent): fix potential null pointer dereference.

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>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andreas Mohr 2018-01-03 17:22:59 +00:00 committed by Andrew Borodin
parent 6aa2cb1cad
commit ac9e4c321a

View File

@ -4185,7 +4185,7 @@ panel_recursive_cd_to_parent (const vfs_path_t * vpath)
/* check if path contains only '/' */
panel_cwd_path = vfs_path_as_str (cwd_vpath);
if (IS_PATH_SEP (panel_cwd_path[0]) && panel_cwd_path[1] == '\0')
if (panel_cwd_path != NULL && IS_PATH_SEP (panel_cwd_path[0]) && panel_cwd_path[1] == '\0')
return NULL;
tmp_vpath = vfs_path_vtokens_get (cwd_vpath, 0, -1);