summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-11-19 17:17:36 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-11-19 17:17:36 -0800
commitd16e510b31b54969d384b70f2ec83a24dae0b448 (patch)
tree02020b9eb048acb940fa15f44a354af0c63fe247
parentbc06fce990b5bb8559d37eb2d2a7aa8c69ca024b (diff)
downloadsyslinux-d16e510b31b54969d384b70f2ec83a24dae0b448.tar.gz
open: close the file descriptor if the file fails to open
Close the file descriptor (freeing the file structure) when opening a file fails. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/lib/sys/open.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/com32/lib/sys/open.c b/com32/lib/sys/open.c
index aabbec21..aac5e6f4 100644
--- a/com32/lib/sys/open.c
+++ b/com32/lib/sys/open.c
@@ -72,13 +72,14 @@ int open(const char *pathname, int flags, ...)
__com32.cs_intcall(0x22, &regs, &regs);
if ((regs.eflags.l & EFLAGS_CF) || regs.esi.w[0] == 0) {
+ close(fd);
errno = ENOENT;
return -1;
}
{
uint16_t blklg2;
-asm("bsrw %1,%0": "=r"(blklg2):"rm"(regs.ecx.w[0]));
+ asm("bsrw %1,%0" : "=r" (blklg2) : "rm" (regs.ecx.w[0]));
fp->i.blocklg2 = blklg2;
}
fp->i.length = regs.eax.l;