git.annexia.org
/
libguestfs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7c020a1
)
Coverity: Ensure fp is closed along all error paths.
author
Richard W.M. Jones
<rjones@redhat.com>
Wed, 8 Jun 2011 21:30:24 +0000
(22:30 +0100)
committer
Richard W.M. Jones
<rjones@redhat.com>
Thu, 9 Jun 2011 09:53:51 +0000
(10:53 +0100)
daemon/inotify.c
patch
|
blob
|
history
diff --git
a/daemon/inotify.c
b/daemon/inotify.c
index
8e8b690
..
c8862e5
100644
(file)
--- 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;
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];
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 (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;
goto error;
- }
}
fclose (fp);
}
fclose (fp);
+ fp = NULL;
if (add_string (&ret, &size, &alloc, NULL) == -1)
goto error;
if (add_string (&ret, &size, &alloc, NULL) == -1)
goto error;
@@
-376,6
+375,9
@@
do_inotify_files (void)
return ret;
error:
return ret;
error:
+ if (fp != NULL)
+ fclose (fp);
+
unlink ("/tmp/inotify");
return NULL;
#else
unlink ("/tmp/inotify");
return NULL;
#else