diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-06-03 20:24:32 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-06-03 20:24:32 +0100 |
commit | c8ae7446806d5f329b844a098109e83e347e16ce (patch) | |
tree | e8711642cfb96b634cd91011afb3d23661a2cff5 /render/form.c | |
parent | b62fad759a07ee8a652d69147682508647094fdc (diff) | |
download | netsurf-c8ae7446806d5f329b844a098109e83e347e16ce.tar.gz netsurf-c8ae7446806d5f329b844a098109e83e347e16ce.tar.bz2 |
Only iterate the form when freeing a control if there is one.
This fixes Bug#2322
Diffstat (limited to 'render/form.c')
-rw-r--r-- | render/form.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/render/form.c b/render/form.c index 16bf5bbb7..1adce23d8 100644 --- a/render/form.c +++ b/render/form.c @@ -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; + } } } |