X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Finotify.c;h=c8862e552cc4c5d7448a47aae8e4fe0a4d30360c;hb=b3f1457fddd19b1e540866fa01c665aeb371cb44;hp=8e8b690fbb3a65ca081af166057a82c1e142dc23;hpb=33b638109ed66ea360b53b80b1f407b3a5f5ec39;p=libguestfs.git diff --git a/daemon/inotify.c b/daemon/inotify.c index 8e8b690..c8862e5 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