From 28ce91a9011ee1559ef5f7b09f0b23ee8e25fd12 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 18 May 2014 21:31:50 +0200 Subject: [PATCH] WINGs: fix check for NULL pointer in WMFilePanel (Coverity #50195) As pointed by Coverity, there is a NULL pointer check at the end of the function 'deleteFile' (which happens to not be necessary because wfree was made to accept NULL pointers), however there are many things done before that assumes the pointer is not NULL. The check is moved to where it matters. Signed-off-by: Christophe CURIS --- WINGs/wfilepanel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WINGs/wfilepanel.c b/WINGs/wfilepanel.c index 0f128195..be604d7e 100644 --- a/WINGs/wfilepanel.c +++ b/WINGs/wfilepanel.c @@ -695,6 +695,9 @@ static void deleteFile(WMWidget *widget, void *p_panel) (void) widget; file = getCurrentFileName(panel); + if (file == NULL) + return; + normalizePath(file); if (stat(file, &filestat) == -1) { @@ -725,8 +728,7 @@ static void deleteFile(WMWidget *widget, void *p_panel) } out: - if (file) - wfree(file); + wfree(file); } static void goUnmount(WMWidget *widget, void *p_panel)