diff options
author | Dom Lachowicz <domlachowicz@gmail.com> | 2003-10-13 18:25:13 +0000 |
---|---|---|
committer | Dom Lachowicz <domlachowicz@gmail.com> | 2003-10-13 18:25:13 +0000 |
commit | 7a8346dcf5987a5a6f036d981bee7775e68774d4 (patch) | |
tree | 35ad7b81e683b2456d214abf8f001a86b9be2669 | |
parent | 96f2eae12fec761be96cdec8ac42395982b149bc (diff) | |
download | enchant-7a8346dcf5987a5a6f036d981bee7775e68774d4.tar.gz |
more iconv error condition handling
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@20871 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r-- | src/ispell/ispell_checker.cpp | 5 | ||||
-rw-r--r-- | src/myspell/myspell_checker.cpp | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/ispell/ispell_checker.cpp b/src/ispell/ispell_checker.cpp index 8a368b7..3995dfa 100644 --- a/src/ispell/ispell_checker.cpp +++ b/src/ispell/ispell_checker.cpp @@ -334,7 +334,10 @@ ISpellChecker::suggestWord(const char * const utf8Word, size_t length, len_in = l; len_out = (l+1); - g_iconv(m_translate_out, &In, &len_in, &Out, &len_out); + if ((size_t)-1 == g_iconv(m_translate_out, &In, &len_in, &Out, &len_out)) { + *out_n_suggestions = c; + return sugg_arr; + } *(Out) = 0; } diff --git a/src/myspell/myspell_checker.cpp b/src/myspell/myspell_checker.cpp index 4c4108e..462da10 100644 --- a/src/myspell/myspell_checker.cpp +++ b/src/myspell/myspell_checker.cpp @@ -128,7 +128,14 @@ MySpellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug len_out = sizeof(char) * (len_in + 1); char *word = g_new0(char, len_out); out = reinterpret_cast<char *>(word); - g_iconv(m_translate_out, &in, &len_in, &out, &len_out); + if ((size_t)-1 == g_iconv(m_translate_out, &in, &len_in, &out, &len_out)) { + for (size_t j = i; j < *nsug; j++) + free(sugMS[j]); + free(sugMS); + + *nsug = i; + return sug; + } *(out) = 0; sug[i] = word; free(sugMS[i]); |