mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Modify editor refcounter
...to fix segault introduced in daf21d8315
.
Both actions MSG_INIT and MSG_DESTROY should be send to widget. In editor,
if file cannot be open, MSG_INIT isn't sent to, but MSG_DESTROY is. As a
result, a double free is occured in edit_dlg_deinit().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
0aaf74777d
commit
8c92bec6eb
@ -96,7 +96,9 @@ static cb_ret_t edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t
|
||||
static void
|
||||
edit_dlg_init (void)
|
||||
{
|
||||
if (edit_dlg_init_refcounter == 0)
|
||||
edit_dlg_init_refcounter++;
|
||||
|
||||
if (edit_dlg_init_refcounter == 1)
|
||||
{
|
||||
edit_window_state_char = mc_skin_get ("widget-editor", "window-state-char", "*");
|
||||
edit_window_close_char = mc_skin_get ("widget-editor", "window-close-char", "X");
|
||||
@ -105,8 +107,6 @@ edit_dlg_init (void)
|
||||
aspell_init ();
|
||||
#endif
|
||||
}
|
||||
|
||||
edit_dlg_init_refcounter++;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -117,10 +117,7 @@ edit_dlg_init (void)
|
||||
static void
|
||||
edit_dlg_deinit (void)
|
||||
{
|
||||
if (edit_dlg_init_refcounter != 0)
|
||||
edit_dlg_init_refcounter--;
|
||||
|
||||
if (edit_dlg_init_refcounter == 0)
|
||||
if (edit_dlg_init_refcounter == 1)
|
||||
{
|
||||
g_free (edit_window_state_char);
|
||||
g_free (edit_window_close_char);
|
||||
@ -129,6 +126,9 @@ edit_dlg_deinit (void)
|
||||
aspell_clean ();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (edit_dlg_init_refcounter != 0)
|
||||
edit_dlg_init_refcounter--;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user