summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/form_manager.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 19:17:25 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 19:17:25 +0000
commita263d56dd156e94f3453604d231e06a9bb1f537d (patch)
treeb1737da94bee012cd470bbb049d9ca9d9be3d966 /chrome/renderer/form_manager.cc
parent00e1756a97e0502fe0b1f6f726eb3e92888238bc (diff)
downloadchromium_src-a263d56dd156e94f3453604d231e06a9bb1f537d.zip
chromium_src-a263d56dd156e94f3453604d231e06a9bb1f537d.tar.gz
chromium_src-a263d56dd156e94f3453604d231e06a9bb1f537d.tar.bz2
AutoFill: Handle the case where the cached form has extra fields at the end of
the form compared to the FormData. Fixes a crash. BUG=41573 TEST=FormManagerTest.FillFormExtraFieldInCache Review URL: http://codereview.chromium.org/2003002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46600 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/form_manager.cc')
-rw-r--r--chrome/renderer/form_manager.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index e39c3b1..f81d6df 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -414,12 +414,19 @@ bool FormManager::FillForm(const FormData& form) {
// so loop past non-matching fields in the set with more elements.
while (form_element->control_elements[i].nameForAutofill() !=
form.fields[j].name()) {
- if (form_element->control_elements.size() > form.fields.size())
+ if (form_element->control_elements.size() > form.fields.size()) {
+ // We're at the end of the elements already.
+ if (i + 1 == form_element->control_elements.size())
+ break;
++i;
- else if (form.fields.size() > form_element->control_elements.size())
+ } else if (form.fields.size() > form_element->control_elements.size()) {
+ // We're at the end of the elements already.
+ if (j + 1 == form.fields.size())
+ break;
++j;
- else
+ } else {
NOTREACHED();
+ }
continue;
}