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 /winsup/cygwin/dtable.cc
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.
Diffstat (limited to 'winsup/cygwin/dtable.cc')
-rw-r--r--winsup/cygwin/dtable.cc16
1 files changed, 10 insertions, 6 deletions
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