From 470b8544e8d48d05b9210a7de38fe76b65e29658 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 3 Jul 2013 20:26:44 +0000 Subject: * fhandler.cc (fhandler_base::close_with_arch): Make sure that the archetype is deleted when close_with_arch is referenced *via* the archetype. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/fhandler.cc | 30 ++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e3a9f46..3f74bf2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2013-07-03 Christopher Faylor + + * fhandler.cc (fhandler_base::close_with_arch): Make sure that the + archetype is deleted when close_with_arch is referenced *via* the + archetype. + 2013-06-28 Corinna Vinschen * path.cc (find_fast_cwd_pointer): Use gas syntax for assembler diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 6c284a5..920ab7f 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1076,32 +1076,30 @@ fhandler_base::close_with_arch () fhandler_base *fh; if (usecount) { - if (!--usecount) - debug_printf ("closing passed in archetype, usecount %d", usecount); - else + /* This was the archetype itself. */ + if (--usecount) { - debug_printf ("not closing passed in archetype, usecount %d", usecount); + debug_printf ("not closing passed in archetype %p, usecount %d", archetype, usecount); return 0; } - fh = this; + debug_printf ("closing passed in archetype %p, usecount %d", archetype, usecount); + /* Set archetype temporarily so that it will eventually be deleted. */ + archetype = fh = this; } else if (!archetype) fh = this; + else if (archetype_usecount (-1) == 0) + { + debug_printf ("closing archetype"); + fh = archetype; + } else { - cleanup (); - if (archetype_usecount (-1) == 0) - { - debug_printf ("closing archetype"); - fh = archetype; - } - else - { - debug_printf ("not closing archetype"); - return 0; - } + debug_printf ("not closing archetype"); + return 0; } + cleanup (); res = fh->close (); if (archetype) { -- cgit v1.1