[Spellcheck] Fix crash in no-suggestions case.
commit9681cc8a90fda51924a8dd98e62d177bea14801f
authorgroby <groby@chromium.org>
Wed, 16 Sep 2015 18:41:56 +0000 (16 11:41 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 16 Sep 2015 18:42:53 +0000 (16 18:42 +0000)
treed93578e792dfb67d9266e6d52ee685aaa43d0c9d
parent2d76d6f84658353d00d6c9a1a4f164df8478ada6
[Spellcheck] Fix crash in no-suggestions case.

The FillSuggestions_OneLanguageNoSuggestions would crash with the old
FillSuggestions version, since it would loop essentially unbounded for
an empty suggestions vector.

The new version also simplifies the logic into a somewhat more clear
form. It runs potentially a few iterations more than the previous one,
but has easily understood bounds which will hopefully avoid further
under/overruns. (Famous last words! ;)

Also added a few more test cases for FillSuggestions, while I'm here.

BUG=524657

Review URL: https://codereview.chromium.org/1308313007

Cr-Commit-Position: refs/heads/master@{#349171}
chrome/renderer/spellchecker/spellcheck.cc
chrome/renderer/spellchecker/spellcheck_unittest.cc