Bug 698: Keep forms contiguous and non-overlapping and start from 0.
commit386a5d517b5996112bc5a75b1a1b917c7adffe88
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>
Mon, 14 Jul 2008 12:02:06 +0000 (14 15:02 +0300)
treed520cc95c0fd0bc943112e15cf3f9c3e4000e5e7
parent988cec481bd8e0e41b2c7bd717a3d9af215f00e2
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
NEWS
src/document/html/renderer.c