From dda8161ece15c69bb222e5c72ab8e5479a7eb8cc Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 3 Feb 2007 01:59:49 +0000 Subject: [PATCH] hangup paranoia (trunk only) If nhwindows_hangup() were to get called a second time, it would have saved hup_exit_nhwindows() as the previous interface's shutdown routine. Then if/when exit_nhwindows() gets called, hup_exit_nhwindows() would have called itself with uncontrolled recursion. So guard against that by preventing the hangup shutdown routine from ever being saved as previous interface shutdown routine. Also, avoid the exit_windows macro when using it as a pointer rather than for a function call, since pre-ANSI compilers might be confused by its expansion. --- src/windows.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/windows.c b/src/windows.c index 36a92b10b..56afc7435 100644 --- a/src/windows.c +++ b/src/windows.c @@ -313,8 +313,9 @@ nhwindows_hangup() /* don't call exit_nhwindows() directly here; if a hangup occurs while interface code is executing, exit_nhwindows could knock the interface's active data structures out from under itself */ - if (iflags.window_inited) - previnterface_exit_nhwindows = exit_nhwindows; + if (iflags.window_inited && + windowprocs.win_exit_nhwindows != hup_exit_nhwindows) + previnterface_exit_nhwindows = windowprocs.win_exit_nhwindows; windowprocs = hup_procs; }