diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-03-08 11:39:50 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-03-08 13:21:58 +0000 |
commit | cba36e730524525b5fc1c0df2ec3dd878d55ff15 (patch) | |
tree | 5f2c59440172c703a60ce96d3f09d1045fbc75f5 /daemon/9p.c | |
parent | 855aaf414af3b8c8ca1f722a589fd251cc8317ee (diff) | |
download | libguestfs-cba36e730524525b5fc1c0df2ec3dd878d55ff15.tar.gz libguestfs-cba36e730524525b5fc1c0df2ec3dd878d55ff15.tar.xz libguestfs-cba36e730524525b5fc1c0df2ec3dd878d55ff15.zip |
daemon: 9p: Close fd along error paths (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:130: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:130: var_assign: Assigning: "fd" = handle returned from "open(filename, 0)".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:142: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:149: noescape: Variable "fd" is not closed or saved in function "read".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:153: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
Diffstat (limited to 'daemon/9p.c')
-rw-r--r-- | daemon/9p.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/daemon/9p.c b/daemon/9p.c index 3ab1044f..e9e0ac1e 100644 --- a/daemon/9p.c +++ b/daemon/9p.c @@ -139,6 +139,7 @@ read_whole_file (const char *filename) if (r2 == NULL) { perror ("realloc"); free (r); + close (fd); return NULL; } r = r2; @@ -150,6 +151,7 @@ read_whole_file (const char *filename) if (n == -1) { perror (filename); free (r); + close (fd); return NULL; } if (n == 0) |