always unlink merged temporary files if an error occurs
diff --git a/lib/worktree.c b/lib/worktree.c
index dfe5cb1..a8f6827 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -810,11 +810,13 @@ merge_file(int *local_changes_subsumed, struct got_worktree *worktree,
if (rename(merged_path, ondisk_path) != 0) {
err = got_error_from_errno3("rename", merged_path,
ondisk_path);
- unlink(merged_path);
goto done;
}
-
done:
+ if (err) {
+ if (merged_path)
+ unlink(merged_path);
+ }
if (merged_fd != -1 && close(merged_fd) != 0 && err == NULL)
err = got_error_from_errno("close");
if (f_orig && fclose(f_orig) != 0 && err == NULL)