Skip to content

Commit

Permalink
mapfile: Fix fp leaks in error path
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrewery committed Nov 19, 2018
1 parent 23069cb commit 07718b6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/poudriere-sh/mapfile.c
Expand Up @@ -154,12 +154,14 @@ mapfilecmd(int argc, char **argv)
}
if (fstat(fileno(fp), &sb) != 0) {
serrno = errno;
fclose(fp);
INTON;
errno = serrno;
err(EX_OSERR, "%s", "fstat");
}
if (!(S_ISFIFO(sb.st_mode) || S_ISREG(sb.st_mode))) {
serrno = errno;
fclose(fp);
INTON;
errno = serrno;
errx(EX_DATAERR, "%s not a regular file or FIFO",
Expand All @@ -182,6 +184,7 @@ mapfilecmd(int argc, char **argv)

if ((newfd = fcntl(fileno(fp), cmd, 10)) == -1) {
serrno = errno;
fclose(fp);
INTON;
errno = serrno;
err(EX_NOINPUT, "%s", "fcntl");
Expand Down

0 comments on commit 07718b6

Please sign in to comment.