diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-06-08 22:30:24 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-06-13 14:22:19 +0100 |
commit | 759e6d537c9e6413def2cc88e6c07bce53f09025 (patch) | |
tree | c4afdffe81abeadd5ac635d87d3975ee06e7aa5d | |
parent | 8a493c4ebb872a93fbe337639d5e58ab70694f37 (diff) | |
download | libguestfs-759e6d537c9e6413def2cc88e6c07bce53f09025.tar.gz libguestfs-759e6d537c9e6413def2cc88e6c07bce53f09025.tar.xz libguestfs-759e6d537c9e6413def2cc88e6c07bce53f09025.zip |
Coverity: Ensure fp is closed along all error paths.
(cherry picked from commit 346c5b0ebf58c81f657540eeb72abaa41bfc4e3f)
-rw-r--r-- | daemon/inotify.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/daemon/inotify.c b/daemon/inotify.c index 8e8b690f..c8862e55 100644 --- a/daemon/inotify.c +++ b/daemon/inotify.c @@ -314,7 +314,7 @@ do_inotify_files (void) char **ret = NULL; int size = 0, alloc = 0; unsigned int i; - FILE *fp; + FILE *fp = NULL; guestfs_int_inotify_event_list *events; char buf[PATH_MAX]; @@ -361,13 +361,12 @@ do_inotify_files (void) if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0'; - if (add_string (&ret, &size, &alloc, buf) == -1) { - fclose (fp); + if (add_string (&ret, &size, &alloc, buf) == -1) goto error; - } } fclose (fp); + fp = NULL; if (add_string (&ret, &size, &alloc, NULL) == -1) goto error; @@ -376,6 +375,9 @@ do_inotify_files (void) return ret; error: + if (fp != NULL) + fclose (fp); + unlink ("/tmp/inotify"); return NULL; #else |