attempting to drop a subset of a stack of multiple cursed loadstones could
corrupt inventory or cause a crash
"miss" message was missing for thrown or kicked gold not caught by a monster
+prevent recursive impossible() and panic() calls from leading to a stack overflow
Platform- and/or Interface-Specific Fixes
int panicking; /* `panic' is in progress */
#if defined(VMS) || defined(WIN32)
int exiting; /* an exit handler is executing */
+#endif
+ int in_impossible;
+#ifdef PANICLOG
+ int in_paniclog;
#endif
} program_state;
FILE *lfile;
char buf[BUFSZ];
- lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX);
- if (lfile) {
- (void) fprintf(lfile, "%s %08ld: %s %s\n",
- version_string(buf), yyyymmdd((time_t)0L),
- type, reason);
- (void) fclose(lfile);
+ if (!program_state.in_paniclog) {
+ program_state.in_paniclog = 1;
+ lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX);
+ if (lfile) {
+ (void) fprintf(lfile, "%s %08ld: %s %s\n",
+ version_string(buf), yyyymmdd((time_t)0L),
+ type, reason);
+ (void) fclose(lfile);
+ }
+ program_state.in_paniclog = 0;
}
#endif /* PANICLOG */
return;
impossible VA_DECL(const char *, s)
VA_START(s);
VA_INIT(s, const char *);
+ if (program_state.in_impossible)
+ panic("impossible called impossible");
+ program_state.in_impossible = 1;
{
char pbuf[BUFSZ];
Vsprintf(pbuf,s,VA_ARGS);
}
vpline(s,VA_ARGS);
pline("Program in disorder - perhaps you'd better #quit.");
+ program_state.in_impossible = 0;
VA_END();
}