fix reported crash of TTY_PERM_INVENT segfaulting

Options processing can be early, even before ttyDisplay is allocated.
If we find that TTY_PERM_INVENT initialization is happening too early,
just set a marker (iflags.perm_invent_pending) to try again a bit later.

The changes in win/share are just to be able to sucessfully
reproduce the original issue on Windows. It was easily reproduced
on Unix, just by building with TTY_PERM_INVENT in include/config.h
and setting OPTIONS=perm_invent in config file.
This commit is contained in:
nhmall
2025-01-02 11:46:15 -05:00
parent 2d4f9893ad
commit d3c57e1b42
8 changed files with 74 additions and 16 deletions

View File

@@ -2262,6 +2262,9 @@ extern int msgtype_type(const char *, boolean) NONNULLARG1;
extern void hide_unhide_msgtypes(boolean, int);
extern void msgtype_free(void);
extern void options_free_window_colors(void);
#ifdef TTY_PERM_INVENT
extern void check_perm_invent_again(void);
#endif
/* ### pager.c ### */

View File

@@ -319,6 +319,7 @@ struct instance_flags {
boolean news; /* print news */
boolean num_pad; /* use numbers for movement commands */
boolean perm_invent; /* display persistent inventory window */
boolean perm_invent_pending; /* need to try again */
boolean renameallowed; /* can change hero name during role selection */
boolean renameinprogress; /* we are changing hero name */
boolean sounds; /* master on/off switch for using soundlib */

View File

@@ -205,6 +205,7 @@ enum to_core_flags {
too_small = 0x002,
prohibited = 0x004,
no_init_done = 0x008,
too_early = 0x010,
};
enum from_core_requests {