Skip to content
Permalink
Browse files

Fixes for resource leak in cbsdsh/cbsd_fwatch function

  • Loading branch information...
olevole committed Feb 5, 2015
1 parent 58f03d9 commit 466a0a9874e5210d1fa013705071574bafc9798e
Showing with 6 additions and 1 deletion.
  1. +6 −1 bin/cbsdsh/cbsd_fwatch.c
@@ -95,7 +95,6 @@ cbsd_fwatchcmd(int argc, char *argv[])
return 1;
}


if ((fd = open(watchfile, O_RDONLY)) == -1) {
out2fmt_flush("Cannot open: %s\n", watchfile);
ckfree(watchfile);
@@ -117,6 +116,7 @@ cbsd_fwatchcmd(int argc, char *argv[])
out2fmt_flush("kevent\n");
close(fd);
ckfree(watchfile);
close(kq);
return 1;
}

@@ -134,9 +134,12 @@ cbsd_fwatchcmd(int argc, char *argv[])
out2fmt_flush("kevent\n");
close(fd);
ckfree(watchfile);
close(kq);
return 1;
}

close(kq);

if (nev != 0) {
if (ev.fflags & NOTE_DELETE) {
out2fmt_flush("deleted\n");
@@ -173,5 +176,7 @@ cbsd_fwatchcmd(int argc, char *argv[])
ev.fflags &= ~NOTE_REVOKE;
}
}

ckfree(watchfile);
return 0;
}

0 comments on commit 466a0a9

Please sign in to comment.
You can’t perform that action at this time.