diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-03-08 11:44:31 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-03-08 13:21:59 +0000 |
commit | d0453c02545c825810fec6e5874c55d7ac5ec678 (patch) | |
tree | bccf4ccea2ba935ecbbf40f080ac2604bc51e955 | |
parent | fbf10d7f682178a6a71cfa8dbac2acd23f869597 (diff) | |
download | libguestfs-d0453c02545c825810fec6e5874c55d7ac5ec678.tar.gz libguestfs-d0453c02545c825810fec6e5874c55d7ac5ec678.tar.xz libguestfs-d0453c02545c825810fec6e5874c55d7ac5ec678.zip |
daemon: proto: Close fd along error paths (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:894: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:894: var_assign: Assigning: "fd" = handle returned from "open(filename, 0)".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:903: noescape: Variable "fd" is not closed or saved in function "read".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:911: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:918: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
-rw-r--r-- | src/proto.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/proto.c b/src/proto.c index ee949dd6..1ab8d187 100644 --- a/src/proto.c +++ b/src/proto.c @@ -908,6 +908,7 @@ guestfs___send_file (guestfs_h *g, const char *filename) if (err < 0) { if (err == -2) /* daemon sent cancellation */ send_file_cancellation (g); + close (fd); return err; } } @@ -915,6 +916,7 @@ guestfs___send_file (guestfs_h *g, const char *filename) if (r == -1) { perrorf (g, "read: %s", filename); send_file_cancellation (g); + close (fd); return -1; } @@ -922,6 +924,7 @@ guestfs___send_file (guestfs_h *g, const char *filename) error (g, _("operation cancelled by user")); g->last_errnum = EINTR; send_file_cancellation (g); + close (fd); return -1; } |