From ed32dd8946982ea5e49978a5273d6c43991bb4e9 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 2 Apr 2010 14:11:45 +0000 Subject: [PATCH] * fhandler_tty.cc (fhandler_tty_slave::close): Avoid potential crash if former open call has been unsuccessful. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler_tty.cc | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a57cd0864..4a091f2e9 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2010-04-02 Corinna Vinschen + + * fhandler_tty.cc (fhandler_tty_slave::close): Avoid potential crash + if former open call has been unsuccessful. + 2010-04-01 Corinna Vinschen * nlsfuncs.cc: Fix indentation. diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 4e4dc5338..e9471ce5d 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -613,10 +613,11 @@ fhandler_tty_slave::close () close this normally. cgf 2006-05-20 */ cygheap->manage_console_count ("fhandler_tty_slave::close", -1); - archetype->usecount--; + if (archetype) + archetype->usecount--; report_tty_counts (this, "closed", ""); - if (archetype->usecount) + if (archetype && archetype->usecount) { #ifdef DEBUGGING if (archetype->usecount < 0)