Bug 698: Keep forms contiguous and non-overlapping and start from 0.
commit83ccaa367316e944b3c5d5ab672526e0de55b670
authorKalle Olavi Niemitalo <kon@iki.fi>
Mon, 14 Jul 2008 12:02:06 +0000 (14 15:02 +0300)
committerKalle Olavi Niemitalo <Kalle@Astalo.kon.iki.fi>
Sun, 20 Jul 2008 08:46:01 +0000 (20 11:46 +0300)
tree66a85dbfc461e23308057da4de6f97e567604dc2
parent85bfba4530c6a96fc3b07ca7da18f48456b1bfe8
Bug 698: Keep forms contiguous and non-overlapping and start from 0.

In document.forms, each struct form has form_num and form_end members
that reserve a subrange of [0, INT_MAX] to that form.  Previously,
multiple forms in the list could have form_end == INT_MAX and thus
overlap each other.  Prevent that by adjusting form_end of each form
newly added to the list.

Revert 438f039bda7d424f79502b3f83e99cedcb7f7ae9,
"check_html_form_hierarchy: Old code was buggy.", which made
check_html_form_hierarchy attach controls to the wrong forms.
Instead, construct the dummy form ("for those Flying Dutchmans") at
form_num == 0 always before adding any real forms to the list.
This prevents the assertion failure by ensuring that every possible
form_control.position is covered by some form, if there are any forms.

Add a function assert_forms_list_ok, which checks that the set of
forms actually covers the [0, INT_MAX] range without overlapping,
as intended.  Call that from check_html_form_hierarchy to detect
any corruption.

I have tested this code (before any cherry-picking) with:
- bug 613 attachment 210: didn't crash
- bug 714 attachment 471: didn't crash
- bug 961 attachment 382: didn't crash
- bug 698 attachment 239: all the submit buttons showed the right URLs
- bug 698 attachment 470: the submit button showed the right URL

(cherry picked from commit 386a5d517b5996112bc5a75b1a1b917c7adffe88)
NEWS
src/document/html/renderer.c