diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index ef26def6..b22ecd9c 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -119,10 +119,7 @@ destroy_terminal(struct terminal *term) bookmark_auto_save_tabs(term); #endif - if (term->textarea_data) { - done_textarea_data(term->textarea_data); - term->textarea_data = NULL; - } + free_textarea_data(term); /* delete_window doesn't update term->current_tab, but it calls redraw_terminal, which requires term->current_tab diff --git a/src/viewer/text/textarea.c b/src/viewer/text/textarea.c index 784929cf..bd89c374 100644 --- a/src/viewer/text/textarea.c +++ b/src/viewer/text/textarea.c @@ -599,13 +599,22 @@ init_textarea_data(struct terminal *term, struct form_state *fs, return td; } -void +static void done_textarea_data(struct textarea_data *td) { mem_free(td->fn); mem_free(td); } +void +free_textarea_data(struct terminal *term) +{ + assert(term); + + if (term->textarea_data) + done_textarea_data(term->textarea_data); +} + void textarea_edit(int op, struct terminal *term_, struct form_state *fs_, struct document_view *doc_view_, struct link *link_) diff --git a/src/viewer/text/textarea.h b/src/viewer/text/textarea.h index 865fa9d5..cd7b6a6e 100644 --- a/src/viewer/text/textarea.h +++ b/src/viewer/text/textarea.h @@ -21,7 +21,7 @@ int area_cursor(struct form_control *fc, struct form_state *fs); void draw_textarea(struct terminal *term, struct form_state *fs, struct document_view *doc_view, struct link *link); unsigned char *encode_textarea(struct submitted_value *sv); -void done_textarea_data(struct textarea_data *td); +void free_textarea_data(struct terminal *term); void textarea_edit(int, struct terminal *, struct form_state *, struct document_view *, struct link *); void menu_textarea_edit(struct terminal *term, void *xxx, void *ses_);