]> granicus.if.org Git - nethack/commitdiff
hangup paranoia (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 3 Feb 2007 01:59:49 +0000 (01:59 +0000)
committernethack.rankin <nethack.rankin>
Sat, 3 Feb 2007 01:59:49 +0000 (01:59 +0000)
     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

index 36a92b10b722cc51b0e30b2342d75a435196ea78..56afc7435819ed1b3a7ee3b8564856ea9999735c 100644 (file)
@@ -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;
 }