From e828e1c074732c9f670dd621baf1fae59261040f Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Fri, 14 May 2021 19:45:56 +0200 Subject: [PATCH] Fix use-after-free error in wIconStore reported by Coverity The function always returns the filename where the icon have been saved, but in the case where the save operation failed we would free the memory for that file name, yet still return this pointer like if it were valid. Took opportunity to remove redundant free(path) which is done a couple lines later, because redundancy is a source of problem for code maintenance. Signed-off-by: Christophe CURIS --- src/icon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/icon.c b/src/icon.c index 6f5f02e9..e823fecd 100644 --- a/src/icon.c +++ b/src/icon.c @@ -518,9 +518,8 @@ char *wIconStore(WIcon *icon) } if (!RSaveImage(image, path, "XPM")) { - wfree(path); wfree(filename); - path = NULL; + filename = NULL; } wfree(path);