From d89cebc0b3f0c693a7d40f80ad6c52ef92cb9902 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Tue, 17 Feb 2009 09:11:22 +0100 Subject: [PATCH] bug 762: Fix memory leak in ses_goto. In src/session/task.c, if ses_goto() was going to ask the user to confirm, it did: task->session_task.target.frame = null_or_stracpy(target_frame); It added the struct task to a memory_list, so the structure was freed when the message box was closed. The target frame string was however never freed. To fix this leak, add the target frame string to the memory_list too. Alternatively, this could have been fixed by making post_yes() and post_no() free the string. It is however a bit better to use the memory_list because msg_box() frees that even if it is unable to display the message box. --- NEWS | 1 + src/session/task.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index eaf4109a..8d723867 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,7 @@ Miscellaneous: document.css.media. * bug 638: Propagate the existence of $DISPLAY from slave terminals to mailcap test commands. +* bug 762: Small memory leak in goto_current_link/goto_imgmap * bug 963: New option document.css.ignore_display_none. * bug 977: Fixed crash when opening in new tab a non link with onclick attribute. diff --git a/src/session/task.c b/src/session/task.c index e2c4f677..84073caf 100644 --- a/src/session/task.c +++ b/src/session/task.c @@ -173,6 +173,7 @@ ses_goto(struct session *ses, struct uri *uri, unsigned char *target_frame, int confirm_submit = uri->form && get_opt_bool("document.browse.forms" ".confirm_submit", ses); unsigned char *m1 = NULL, *message = NULL; + struct memory_list *mlist = NULL; if (ses->doc_view && ses->doc_view->document @@ -272,7 +273,10 @@ ses_goto(struct session *ses, struct uri *uri, unsigned char *target_frame, mem_free_if(uristring); } - msg_box(ses->tab->term, getml(task, (void *) NULL), MSGBOX_FREE_TEXT, + add_to_ml(&mlist, task, (void *) NULL); + if (task->session_task.target.frame) + add_to_ml(&mlist, task->session_task.target.frame, (void *) NULL); + msg_box(ses->tab->term, mlist, MSGBOX_FREE_TEXT, N_("Warning"), ALIGN_CENTER, message, task, 2,