Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3327)

Unified Diff: chrome/renderer/spellchecker/spellcheck_unittest.cc

Issue 2136333003: [Hunspell, Fuzz] Testcase Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/spellchecker/hunspell_engine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/spellchecker/spellcheck_unittest.cc
diff --git a/chrome/renderer/spellchecker/spellcheck_unittest.cc b/chrome/renderer/spellchecker/spellcheck_unittest.cc
index 05986fa22e1489bcd29027ccb5c7e55778cc8fd1..fc89c86d534a7b4961e63c439c5461c0e1a6fb84 100644
--- a/chrome/renderer/spellchecker/spellcheck_unittest.cc
+++ b/chrome/renderer/spellchecker/spellcheck_unittest.cc
@@ -26,6 +26,7 @@
#include "third_party/WebKit/public/platform/WebVector.h"
#include "third_party/WebKit/public/web/WebTextCheckingCompletion.h"
#include "third_party/WebKit/public/web/WebTextCheckingResult.h"
+#include "third_party/hunspell/src/hunspell/hunspell.hxx"
#define TYPOGRAPHICAL_APOSTROPHE L"\x2019"
@@ -84,6 +85,12 @@ class SpellCheckTest : public testing::Test {
#endif
}
+ HunspellEngine* GetHunspellEngine() {
+ // We're guaranteed this is a HunspellEngine. FOR REALZ.
+ return static_cast<HunspellEngine*>(
+ spell_check_->languages_.front()->platform_spelling_engine_.get());
+ }
+
~SpellCheckTest() override {}
SpellCheck* spell_check() { return spell_check_.get(); }
@@ -1569,3 +1576,34 @@ TEST_F(SpellCheckTest, FillSuggestions_ThreeLanguages) {
EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]);
EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]);
}
+
+TEST_F(SpellCheckTest, Suggestions_Crasher) {
+ const char kTrigger[] =
+ "R:<?xl<<?x(ml?>Ω<abuts?xºml?>b<?xe?<}\r"
+ ":'€<abuts?xml?>b<?x-?->paralleldi!pe.Tselctionp";
+
+ int misspelling_start = 0;
+ int misspelling_length = 0;
+ std::vector<base::string16> suggestions;
+
+ bool result = spell_check()->SpellCheckWord(
+ base::UTF8ToUTF16(kTrigger).c_str(), kNoOffset,
+ static_cast<int>(strlen(kTrigger)), kNoTag, &misspelling_start,
+ &misspelling_length, &suggestions);
+
+ EXPECT_NE(0, misspelling_length);
+ EXPECT_FALSE(result);
+
+ // We're guaranteed this is a HunspellEngine. FOR REALZ.
+ HunspellEngine* engine = GetHunspellEngine();
+ ASSERT_NE(nullptr, engine);
+
+ Hunspell* hunspell = engine->get_hunspell();
+ ASSERT_NE(nullptr, hunspell);
+
+ char** suggest = nullptr;
+ int suggestion_length = hunspell->suggest(&suggest, kTrigger);
+ hunspell->free_list(&suggest, suggestion_length);
+
+ LOG(ERROR) << "Length:" << suggestion_length;
+}
« no previous file with comments | « chrome/renderer/spellchecker/hunspell_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698