Only call close if fd and fd1 are not -1.

CID: 1384018, 1384017
This commit is contained in:
Warner Losh 2018-01-05 05:34:14 +00:00
parent b98c751962
commit 783d8ed04e

View File

@ -717,8 +717,10 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
rv = 0;
done:
free(img);
close(fd);
close(fd1);
if (fd != -1)
close(fd);
if (fd1 != -1)
close(fd1);
return rv;
}