diff --git a/gtkedit/edit.c b/gtkedit/edit.c index 7eea24271..80ccad103 100644 --- a/gtkedit/edit.c +++ b/gtkedit/edit.c @@ -229,6 +229,7 @@ WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, co #endif if (!edit) { edit = malloc (sizeof (WEdit)); + memset (edit, 0, sizeof (sizeof (WEdit))); to_free = 1; } if (!edit) { diff --git a/gtkedit/edit.h b/gtkedit/edit.h index 6da1ee0a7..474e949f7 100644 --- a/gtkedit/edit.h +++ b/gtkedit/edit.h @@ -661,7 +661,7 @@ extern int gtk_edit_fixed_font; # else -# define WIN_MESSAGES edit->widget->mainid, 20, 20 +# define WIN_MESSAGES edit->widget ? edit->widget->mainid : CRoot, 20, 20 # endif diff --git a/gtkedit/editwidget.c b/gtkedit/editwidget.c index 58eddb856..8e43eedc9 100644 --- a/gtkedit/editwidget.c +++ b/gtkedit/editwidget.c @@ -317,7 +317,7 @@ CWidget *CDrawEditor (const char *identifier, Window parent, int x, int y, mkdir (catstrs (home_dir, EDIT_DIR, 0), 0700); made_directory = 1; } - e = w->editor = edit_init (0, height / FONT_PIX_PER_LINE, width / FONT_MEAN_WIDTH, filename, text, starting_directory, text_size); + e = w->editor = CMalloc (sizeof (WEdit)); w->funcs = mouse_funcs_new (w->editor, &edit_mouse_funcs); if (!w->editor) { @@ -326,8 +326,10 @@ CWidget *CDrawEditor (const char *identifier, Window parent, int x, int y, return 0; } w->editor->widget = w; + w->editor = edit_init (e, height / FONT_PIX_PER_LINE, width / FONT_MEAN_WIDTH, filename, text, starting_directory, text_size); w->funcs->data = (void *) w->editor; - if (!e) { + if (!w->editor) { + free (e); CDestroyWidget (w->ident); return 0; }