summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SwifTools/HunspellChecker.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/SwifTools/HunspellChecker.cpp b/SwifTools/HunspellChecker.cpp
index e9bc558..4c3f634 100644
--- a/SwifTools/HunspellChecker.cpp
+++ b/SwifTools/HunspellChecker.cpp
@@ -27,15 +27,17 @@ bool HunspellChecker::isCorrect(const std::string& word) {
void HunspellChecker::getSuggestions(const std::string& word, std::vector<std::string>& list) {
char **suggestList = NULL;
- int words_returned;
+ int words_returned = 0;
if (!word.empty()) {
words_returned = speller_->suggest(&suggestList, word.c_str());
+ if (suggestList != NULL) {
+ for (int i = 0; i < words_returned; ++i) {
+ list.push_back(suggestList[i]);
+ free(suggestList[i]);
+ }
+ free(suggestList);
+ }
}
- for (int i = 0; i < words_returned; ++i) {
- list.push_back(suggestList[i]);
- free(suggestList[i]);
- }
- free(suggestList);
}
void HunspellChecker::checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) {