1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

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.
This commit is contained in:
Kalle Olavi Niemitalo 2009-02-17 09:11:22 +01:00 committed by Witold Filipczyk
parent b41e738905
commit d89cebc0b3
2 changed files with 6 additions and 1 deletions

1
NEWS
View File

@ -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.

View File

@ -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,