summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc2
-rw-r--r--chrome/renderer/spellchecker/spellcheck.cc26
-rw-r--r--ipc/ipc_platform_file.h8
3 files changed, 28 insertions, 8 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index bb7e99d..a6f02a3 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -993,7 +993,7 @@ void BrowserRenderProcessHost::InitSpellChecker() {
prefs->GetBoolean(prefs::kEnableAutoSpellCorrect)));
} else {
Send(new ViewMsg_SpellChecker_Init(
- IPC::PlatformFileForTransit(),
+ IPC::InvalidPlatformFileForTransit(),
std::vector<std::string>(),
std::string(),
false));
diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc
index 3fa20f8..7bc2322 100644
--- a/chrome/renderer/spellchecker/spellcheck.cc
+++ b/chrome/renderer/spellchecker/spellcheck.cc
@@ -182,6 +182,8 @@ void SpellCheck::InitializeHunspell() {
DHISTOGRAM_TIMES("Spellcheck.InitTime",
TimeTicks::Now() - start_time);
+ } else {
+ NOTREACHED() << "Could not mmap spellchecker dictionary.";
}
}
@@ -201,11 +203,9 @@ bool SpellCheck::InitializeIfNeeded() {
return true;
}
- // Check if the platform spellchecker is being used.
- if (file_ != base::kInvalidPlatformFileValue) {
- // If it isn't, init hunspell.
+ // Don't initialize if hunspell is disabled.
+ if (file_ != base::kInvalidPlatformFileValue)
InitializeHunspell();
- }
return false;
}
@@ -223,9 +223,15 @@ bool SpellCheck::CheckSpelling(const string16& word_to_check, int tag) {
std::string word_to_check_utf8(UTF16ToUTF8(word_to_check));
// Hunspell shouldn't let us exceed its max, but check just in case
if (word_to_check_utf8.length() < MAXWORDUTF8LEN) {
- // |hunspell_->spell| returns 0 if the word is spelled correctly and
- // non-zero otherwsie.
- word_correct = (hunspell_->spell(word_to_check_utf8.c_str()) != 0);
+ if (hunspell_.get()) {
+ // |hunspell_->spell| returns 0 if the word is spelled correctly and
+ // non-zero otherwsie.
+ word_correct = (hunspell_->spell(word_to_check_utf8.c_str()) != 0);
+ } else {
+ // If |hunspell_| is NULL here, an error has occurred, but it's better
+ // to check rather than crash.
+ word_correct = true;
+ }
}
}
@@ -241,6 +247,12 @@ void SpellCheck::FillSuggestionList(
wrong_word, optional_suggestions));
return;
}
+
+ // If |hunspell_| is NULL here, an error has occurred, but it's better
+ // to check rather than crash.
+ if (!hunspell_.get())
+ return;
+
char** suggestions;
int number_of_suggestions =
hunspell_->suggest(&suggestions, UTF16ToUTF8(wrong_word).c_str());
diff --git a/ipc/ipc_platform_file.h b/ipc/ipc_platform_file.h
index 4307412..7ba7414 100644
--- a/ipc/ipc_platform_file.h
+++ b/ipc/ipc_platform_file.h
@@ -21,6 +21,14 @@ typedef base::PlatformFile PlatformFileForTransit;
typedef base::FileDescriptor PlatformFileForTransit;
#endif
+inline PlatformFileForTransit InvalidPlatformFileForTransit() {
+#if defined(OS_WIN)
+ return base::kInvalidPlatformFileValue;
+#elif defined(OS_POSIX)
+ return base::FileDescriptor();
+#endif
+}
+
inline base::PlatformFile PlatformFileForTransitToPlatformFile(
const PlatformFileForTransit& transit) {
#if defined(OS_WIN)