Only iterate the form when freeing a control if there is one.

This fixes Bug#2322
This commit is contained in:
Daniel Silverstone 2015-06-03 20:24:32 +01:00
parent b62fad759a
commit c8ae744680
1 changed files with 16 additions and 14 deletions

View File

@ -253,20 +253,22 @@ void form_free_control(struct form_control *control)
}
/* unlink the control from the form */
for (c = control->form->controls; c != NULL; c = c->next) {
if (c->next == control) {
c->next = control->next;
if (control->form->last_control == control)
control->form->last_control = c;
break;
}
if (c == control) {
/* can only happen if control was first control */
control->form->controls = control->next;
if (control->form->last_control == control)
control->form->controls =
control->form->last_control = NULL;
break;
if (control->form != NULL) {
for (c = control->form->controls; c != NULL; c = c->next) {
if (c->next == control) {
c->next = control->next;
if (control->form->last_control == control)
control->form->last_control = c;
break;
}
if (c == control) {
/* can only happen if control was first control */
control->form->controls = control->next;
if (control->form->last_control == control)
control->form->controls =
control->form->last_control = NULL;
break;
}
}
}