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>2009-08-20 12:34:21 +0400
committerCorinna Vinschen <corinna@vinschen.de>2009-08-20 12:34:21 +0400
commit1c1b04b84cfedf7a7c6ce087d9644d6648372676 (patch)
tree2164743f228755601941500265256852b44a165a
parent5546e07b4f4106b0f11d3d1ab206422a636fd42b (diff)
* dtable.cc (build_fh_dev): Take additional bool parameter indicating
whether set_name should be called or not. (dtable::dup_worker): Call build_fh_pc with new second parameter set to false. Explain why. If fhandler's dup failed, delete rather than cfree newfh and set newfh to NULL to indicate failure correctly. * dtable.h (build_fh_pc): Change declaration according to above change. Default set_name parameter to true. * mmap.cc (mmap_record::free_fh): Delete rather than cfree fh.
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/dtable.cc16
-rw-r--r--winsup/cygwin/dtable.h2
-rw-r--r--winsup/cygwin/mmap.cc2
4 files changed, 23 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 1e21dd02f..3d16bbe3b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,14 @@
+2009-08-20 Corinna Vinschen <corinna@vinschen.de>
+
+ * dtable.cc (build_fh_dev): Take additional bool parameter indicating
+ whether set_name should be called or not.
+ (dtable::dup_worker): Call build_fh_pc with new second parameter set
+ to false. Explain why. If fhandler's dup failed, delete rather than
+ cfree newfh and set newfh to NULL to indicate failure correctly.
+ * dtable.h (build_fh_pc): Change declaration according to above change.
+ Default set_name parameter to true.
+ * mmap.cc (mmap_record::free_fh): Delete rather than cfree fh.
+
2009-08-18 Christopher Faylor <me+cygwin@cgf.cx>
* dtable.cc (dtable::fixup_after_exec): Close any popen'ed file handles here.
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 8783a6270..377c138fd 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -444,7 +444,7 @@ build_fh_dev (const device& dev, const char *unix_name)
#define fh_unset ((fhandler_base *) 1)
fhandler_base *
-build_fh_pc (path_conv& pc)
+build_fh_pc (path_conv& pc, bool set_name)
{
fhandler_base *fh = fh_unset;
@@ -564,10 +564,10 @@ build_fh_pc (path_conv& pc)
if (fh == fh_unset)
fh = cnew (fhandler_nodevice) ();
- if (fh)
- fh->set_name (pc);
- else
+ if (!fh)
set_errno (EMFILE);
+ else if (set_name)
+ fh->set_name (pc);
debug_printf ("fh %p", fh);
return fh;
@@ -576,7 +576,10 @@ build_fh_pc (path_conv& pc)
fhandler_base *
dtable::dup_worker (fhandler_base *oldfh)
{
- fhandler_base *newfh = build_fh_pc (oldfh->pc);
+ /* Don't call set_name in build_fh_pc. It will be called in
+ fhandler_base::operator= below. Calling it twice will result
+ in double allocation. */
+ fhandler_base *newfh = build_fh_pc (oldfh->pc, false);
if (!newfh)
debug_printf ("build_fh_pc failed");
else
@@ -585,7 +588,8 @@ dtable::dup_worker (fhandler_base *oldfh)
newfh->set_io_handle (NULL);
if (oldfh->dup (newfh))
{
- cfree (newfh);
+ delete newfh;
+ newfh = NULL;
debug_printf ("oldfh->dup failed");
}
else
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index f685624bc..9d187e819 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -83,7 +83,7 @@ public:
fhandler_base *build_fh_dev (const device&, const char * = NULL);
fhandler_base *build_fh_name (const char *, HANDLE = NULL, unsigned = 0, suffix_info * = NULL);
fhandler_base *build_fh_name (const UNICODE_STRING *, HANDLE = NULL, unsigned = 0, suffix_info * = NULL);
-fhandler_base *build_fh_pc (path_conv& pc);
+fhandler_base *build_fh_pc (path_conv& pc, bool set_name = true);
void dtable_init ();
void stdio_init ();
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index df4cb457a..94dee5e4d 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -536,7 +536,7 @@ void
mmap_record::free_fh (fhandler_base *fh)
{
if (!anonymous ())
- cfree (fh);
+ delete fh;
}
mmap_record *