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 <[email protected]>
---
 WINGs/findfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WINGs/findfile.c b/WINGs/findfile.c
index b5f1b1f..a1e1b02 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;
        }
 
-- 
2.1.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to