mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
daemon: upload: Close fd along error path (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:225: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:225: var_assign: Assigning: "fd" = handle returned from "open(filename, 0)".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:233: noescape: Variable "fd" is not closed or saved in function "lseek".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:235: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
(cherry picked from commit fbf10d7f68)
This commit is contained in:
@@ -232,6 +232,7 @@ do_download_offset (const char *filename, int64_t offset, int64_t size)
|
||||
if (offset) {
|
||||
if (lseek (fd, offset, SEEK_SET) == -1) {
|
||||
reply_with_perror ("lseek: %s", filename);
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user