From 15dce57bc9523d1ba3b36dcbfd6ed347189e1ae6 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 23 Dec 2006 02:11:01 +0200 Subject: [PATCH] Bug 908, activate_link: Set fs->state before the fs pointer becomes invalid. --- src/viewer/text/link.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 40e65e03..02d59232 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1019,6 +1019,13 @@ activate_link(struct session *ses, struct document_view *doc_view, return FRAME_EVENT_REFRESH; } + /* @link_fc->type must be FC_RADIO, then. First turn + * this one on, and then turn off all the other radio + * buttons in the group. Do it in this order because + * further @find_form_state calls may reallocate + * @doc_view->vs->form_info[] and thereby make the @fs + * pointer invalid. */ + fs->state = 1; foreach (form, doc_view->document->forms) { struct form_control *fc; @@ -1027,7 +1034,8 @@ activate_link(struct session *ses, struct document_view *doc_view, foreach (fc, form->items) { if (fc->type == FC_RADIO - && !xstrcmp(fc->name, link_fc->name)) { + && !xstrcmp(fc->name, link_fc->name) + && fc != link_fc) { struct form_state *frm_st; frm_st = find_form_state(doc_view, fc); @@ -1035,7 +1043,6 @@ activate_link(struct session *ses, struct document_view *doc_view, } } } - fs->state = 1; break;