Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-02-15 17:44:11 +0300
committerCorinna Vinschen <corinna@vinschen.de>2011-02-15 17:44:11 +0300
commitfe222f22104df2192684f04fab0847831d114705 (patch)
treed96a9989cd7f0b34ad533061613ead2fdf5074c9 /winsup/cygwin/fhandler_procsys.cc
parentc48947b454fec1bc774059562c217f179e32c0e5 (diff)
* fhandler_procsys.cc (fhandler_procsys::opendir): Avoid SEGV if
opening object directory fails. * fhandler_virtual.cc (fhandler_virtual::opendir): Don't leak memory.
Diffstat (limited to 'winsup/cygwin/fhandler_procsys.cc')
-rw-r--r--winsup/cygwin/fhandler_procsys.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler_procsys.cc b/winsup/cygwin/fhandler_procsys.cc
index 0f4cc1747..6c91a2f9c 100644
--- a/winsup/cygwin/fhandler_procsys.cc
+++ b/winsup/cygwin/fhandler_procsys.cc
@@ -1,6 +1,6 @@
/* fhandler_procsys.cc: fhandler for native NT namespace.
- Copyright 2010 Red Hat, Inc.
+ Copyright 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@@ -245,18 +245,20 @@ fhandler_procsys::opendir (int fd)
OBJECT_ATTRIBUTES attr;
NTSTATUS status;
HANDLE h;
- DIR *dir = fhandler_virtual::opendir (fd);
+ DIR *dir;
mk_unicode_path (&path);
InitializeObjectAttributes (&attr, &path, OBJ_CASE_INSENSITIVE, NULL, NULL);
status = NtOpenDirectoryObject (&h, DIRECTORY_QUERY, &attr);
if (!NT_SUCCESS (status))
{
- free (dir);
__seterrno_from_nt_status (status);
return NULL;
}
- dir->__handle = h;
+ if (!(dir = fhandler_virtual::opendir (fd)))
+ NtClose (h);
+ else
+ dir->__handle = h;
return dir;
}