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:
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/dtable.cc5
-rw-r--r--winsup/cygwin/mmap.cc3
-rw-r--r--winsup/cygwin/path.cc16
4 files changed, 26 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 27d0e4a4f..84fbd3158 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2012-04-07 Christopher Faylor <me.cygwin2012@cgf.cx>
+
+ * dtable.cc (cygwin_attach_handle_to_fd): Defend against NULL return
+ from build_fh_*.
+ (dtable::init_std_file_from_handle): Ditto.
+ * mmap.cc (mmap_record::alloc_fh): Ditto.
+ * path.cc (path_conv::check): Ditto.
+
2012-04-06 Christopher Faylor <me.cygwin2012@cgf.cx>
* fhandler.h (fhandler_base::nohandle): Implement "by hand" rather than
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 15f4c0ce7..498e7fd8d 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -256,6 +256,8 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
if (fd == -1)
fd = cygheap->fdtab.find_unused_handle ();
fhandler_base *fh = build_fh_name (name);
+ if (!fh)
+ return -1;
cygheap->fdtab[fd] = fh;
cygheap->fdtab[fd]->refcnt (1);
fh->init (handle, myaccess, bin ?: fh->pc_binmode ());
@@ -337,6 +339,9 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
else
fh = build_fh_name (name);
+ if (!fh)
+ return;
+
if (name[0])
{
bin = fh->pc_binmode ();
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 2a22a4323..d8d78a51a 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -526,7 +526,8 @@ mmap_record::alloc_fh ()
fdev.name = fdev.native = "";
fdev.parse (get_device ());
fhandler_base *fh = build_fh_dev (fdev);
- fh->set_access (get_openflags ());
+ if (fh)
+ fh->set_access (get_openflags ());
return fh;
}
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 57183da48..3524c0cc0 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -744,13 +744,19 @@ path_conv::check (const char *src, unsigned opt,
{
/* FIXME: Calling build_fhandler here is not the right way to handle this. */
fhandler_virtual *fh = (fhandler_virtual *) build_fh_dev (dev, path_copy);
- virtual_ftype_t file_type = fh->exists ();
- if (file_type == virt_symlink)
+ virtual_ftype_t file_type;
+ if (!fh)
+ file_type = virt_none;
+ else
{
- fh->fill_filebuf ();
- symlen = sym.set (fh->get_filebuf ());
+ file_type = fh->exists ();
+ if (file_type == virt_symlink)
+ {
+ fh->fill_filebuf ();
+ symlen = sym.set (fh->get_filebuf ());
+ }
+ delete fh;
}
- delete fh;
switch (file_type)
{
case virt_directory: