From 0d84b47e9cbf5a6a2ebab6ff9679ffa6eb5e5db2 Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Fri, 3 May 2002 17:28:28 +0000 Subject: [PATCH] Fix fd leak. Threads people: does the call above to `access' need to be underscored as well? PR: 37717 Submitted by: fred@clift.org (slightly modified by me) --- lib/libc/stdtime/localtime.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index 09cfd3ff777..4f36f2b451a 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -316,8 +316,10 @@ struct state * const sp; return -1; if ((fid = _open(name, OPEN_MODE)) == -1) return -1; - if ((_fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) + if ((_fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) { + _close(fid); return -1; + } } { struct tzhead * tzhp;