From a37458eb1e42e0d3398d167a3acd1321cf2f02cd Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 19 Oct 2009 05:01:04 +0000 Subject: fix segfault when radio button lacks name attribute --- src/form.cc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/form.cc b/src/form.cc index bf1b12e0..0f125c95 100644 --- a/src/form.cc +++ b/src/form.cc @@ -257,18 +257,20 @@ static void Html_add_input(DilloHtml *html, DilloHtmlInputType type, */ static DilloHtmlInput *Html_get_radio_input(DilloHtml *html, const char *name) { - lout::misc::SimpleVector* inputs; - - if (html->InFlags & IN_FORM) - inputs = html->getCurrentForm()->inputs; - else - inputs = html->inputs_outside_form; - - for (int idx = 0; idx < inputs->size(); idx++) { - DilloHtmlInput *input = inputs->get(idx); - if (input->type == DILLO_HTML_INPUT_RADIO && - input->name && !dStrcasecmp(input->name, name)) - return input; + if (name) { + lout::misc::SimpleVector* inputs; + + if (html->InFlags & IN_FORM) + inputs = html->getCurrentForm()->inputs; + else + inputs = html->inputs_outside_form; + + for (int idx = 0; idx < inputs->size(); idx++) { + DilloHtmlInput *input = inputs->get(idx); + if (input->type == DILLO_HTML_INPUT_RADIO && + input->name && !dStrcasecmp(input->name, name)) + return input; + } } return NULL; } -- cgit v1.2.3