summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/proto.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/proto.c b/src/proto.c
index 4a558ef7..ee949dd6 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -1133,16 +1133,20 @@ guestfs___recv_file (guestfs_h *g, const char *filename)
if (xwrite (fd, buf, r) == -1) {
perrorf (g, "%s: write", filename);
free (buf);
+ close (fd);
goto cancel;
}
free (buf);
- if (g->user_cancel)
+ if (g->user_cancel) {
+ close (fd);
goto cancel;
+ }
}
if (r == -1) {
error (g, _("%s: error in chunked encoding"), filename);
+ close (fd);
return -1;
}