From 9125cbd7cf47b848390294897561c556a8d8b572 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 6 Jan 2002 03:32:32 +0000 Subject: * dir.cc (opendir): Guarantee release of alloced fhandler structure on error. --- winsup/cygwin/dir.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'winsup/cygwin/dir.cc') diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index 44db5d7be..40411b48c 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -88,14 +88,16 @@ opendir (const char *name) PC_SYM_FOLLOW | PC_FULL, NULL); if (!fh) res = NULL; - else if (!pc.exists ()) - set_errno (ENOENT); + else if (pc.exists ()) + res = fh->opendir (pc); else { - res = fh->opendir (pc); - if (!res) - delete fh; + set_errno (ENOENT); + res = NULL; } + + if (!res && fh) + delete fh; return res; } -- cgit v1.2.3