* fhandler.cc (fhandler_base::close_with_arch): Make sure that the archetype is

deleted when close_with_arch is referenced *via* the archetype.
This commit is contained in:
Christopher Faylor 2013-07-03 20:26:44 +00:00
parent 2404223df6
commit 470b8544e8
2 changed files with 20 additions and 16 deletions

View File

@ -1,3 +1,9 @@
2013-07-03 Christopher Faylor <me.cygwin2013@cgf.cx>
* 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 <corinna@vinschen.de> 2013-06-28 Corinna Vinschen <corinna@vinschen.de>
* path.cc (find_fast_cwd_pointer): Use gas syntax for assembler * path.cc (find_fast_cwd_pointer): Use gas syntax for assembler

View File

@ -1076,21 +1076,19 @@ fhandler_base::close_with_arch ()
fhandler_base *fh; fhandler_base *fh;
if (usecount) if (usecount)
{ {
if (!--usecount) /* This was the archetype itself. */
debug_printf ("closing passed in archetype, usecount %d", usecount); if (--usecount)
else
{ {
debug_printf ("not closing passed in archetype, usecount %d", usecount); debug_printf ("not closing passed in archetype %p, usecount %d", archetype, usecount);
return 0; 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) else if (!archetype)
fh = this; fh = this;
else else if (archetype_usecount (-1) == 0)
{
cleanup ();
if (archetype_usecount (-1) == 0)
{ {
debug_printf ("closing archetype"); debug_printf ("closing archetype");
fh = archetype; fh = archetype;
@ -1100,8 +1098,8 @@ fhandler_base::close_with_arch ()
debug_printf ("not closing archetype"); debug_printf ("not closing archetype");
return 0; return 0;
} }
}
cleanup ();
res = fh->close (); res = fh->close ();
if (archetype) if (archetype)
{ {