From: H. Peter Anvin Date: Fri, 20 Nov 2009 01:17:36 +0000 (-0800) Subject: open: close the file descriptor if the file fails to open X-Git-Tag: syslinux-3.84-pre4~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d16e510b31b54969d384b70f2ec83a24dae0b448;p=platform%2Fupstream%2Fsyslinux.git 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 --- diff --git a/com32/lib/sys/open.c b/com32/lib/sys/open.c index aabbec2..aac5e6f 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, ®s, ®s); 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;