mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-17 09:42:38 +03:00
Ensure we delink form controls when freeing them
This commit is contained in:
parent
e7f9dbcb10
commit
df3a889435
@ -215,6 +215,7 @@ void form_add_control(struct form *form, struct form_control *control)
|
||||
*/
|
||||
void form_free_control(struct form_control *control)
|
||||
{
|
||||
struct form_control *c;
|
||||
assert(control != NULL);
|
||||
|
||||
LOG(("Control:%p name:%p value:%p initial:%p", control, control->name, control->value, control->initial_value));
|
||||
@ -251,6 +252,24 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
free(control);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user