Ticket #4244: fix segfault on dialog before panels get visible.

If some small dialog (error message or password request) is displayed
before main mc window gets visible, the segfault occures.

The cause of segfault is update of prompt that is not created yet.

(setup_mc, create_file_manager): move creation of event channel from
setup_mc() to create_file_manager(), make that after creation of all
file manager widgets.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-05-18 10:09:33 +03:00
parent 333b20557e
commit 0375997c78

View File

@ -859,11 +859,6 @@ setup_mc (void)
#endif /* HAVE_CHARSET */
#endif /* HAVE_SLANG */
#ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell)
add_select_channel (mc_global.tty.subshell_pty, load_prompt, NULL);
#endif /* !ENABLE_SUBSHELL */
if ((tty_baudrate () < 9600) || mc_global.tty.slow_terminal)
verbose = FALSE;
}
@ -942,6 +937,13 @@ create_file_manager (void)
the_bar = buttonbar_new ();
group_add_widget (g, the_bar);
midnight_set_buttonbar (the_bar);
#ifdef ENABLE_SUBSHELL
/* Must be done after creation of cmdline and promt widgets to avoid potential
NULL dereference in load_prompt() -> ... -> setup_cmdline() -> label_set_text(). */
if (mc_global.tty.use_subshell)
add_select_channel (mc_global.tty.subshell_pty, load_prompt, NULL);
#endif /* !ENABLE_SUBSHELL */
}
/* --------------------------------------------------------------------------------------------- */