mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user