mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon: debug: Close fd along error path (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:469: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:469: var_assign: Assigning: "fd" = handle returned from "open("/proc/sys/kernel/core_pattern", 1)".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:474: noescape: Variable "fd" is not closed or saved in function "write".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:476: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
This commit is contained in:
@@ -473,6 +473,7 @@ debug_core_pattern (const char *subcmd, int argc, char *const *const argv)
|
||||
}
|
||||
if (write (fd, pattern, pattern_len) < (ssize_t) pattern_len) {
|
||||
reply_with_perror ("write: " CORE_PATTERN);
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
if (close (fd) == -1) {
|
||||
|
||||
Reference in New Issue
Block a user