From 6ef343ed8795532c8936889a42873735157f0bae Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 25 Apr 2015 12:44:28 +0200 Subject: [PATCH] WUtil: fix improper use of de-allocated variable (Coverity #109618) As pointed by Coverity, the variable 'path_dst' was first free'd, then it was used in the 'unlink' function. This patch fixes the call order to de-allocate the string only when it is no more needed. Signed-off-by: Christophe CURIS --- WINGs/findfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WINGs/findfile.c b/WINGs/findfile.c index b5f1b1f0..a1e1b024 100644 --- a/WINGs/findfile.c +++ b/WINGs/findfile.c @@ -513,9 +513,9 @@ int wcopy_file(const char *dest_dir, const char *src_file, const char *dest_file werror(_("could not close the file \"%s\": %s"), path_dst, strerror(errno)); cleanup_and_return_failure: free(buffer); - wfree(path_dst); close(fd_src); unlink(path_dst); + wfree(path_dst); return -1; }