diff options
author | Reuben Thomas <rrt@sc3d.org> | 2017-11-26 02:31:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-26 02:31:29 +0000 |
commit | ab23b1630f692ed4335a2acdf5f3a644578448ab (patch) | |
tree | 2606ac8660ca7f6e7dba8c86cc1c6e5dc83ecaac /providers | |
parent | 9889e6350eb645feca2b0c061f719ca4188984d5 (diff) | |
parent | 5d1257041e6e84b16ee9adc8d1ec6495adc26103 (diff) | |
download | enchant-ab23b1630f692ed4335a2acdf5f3a644578448ab.tar.gz |
Merge pull request #161 from heftig/master
voikko: Avoid crashing when there are no languages
Diffstat (limited to 'providers')
-rw-r--r-- | providers/enchant_voikko.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/providers/enchant_voikko.c b/providers/enchant_voikko.c index 7af9db4..d6df8ba 100644 --- a/providers/enchant_voikko.c +++ b/providers/enchant_voikko.c @@ -111,16 +111,19 @@ static int voikko_provider_dictionary_exists (struct str_enchant_provider * me _GL_UNUSED_PARAMETER, const char *const tag) { - size_t i, n_dicts; - char ** existing_dicts = voikko_provider_list_dicts (NULL, &n_dicts); + size_t i; + int exists = 0; + char ** voikko_langs = voikkoListSupportedSpellingLanguages (NULL); - for (i = 0; existing_dicts[i] != NULL; i++) { - if (strncmp (tag, existing_dicts[i], strlen (tag)) == 0) { - return 1; + for (i = 0; voikko_langs[i] != NULL; i++) { + if (strncmp (tag, voikko_langs[i], strlen (tag)) == 0) { + exists = 1; + break; } } + voikkoFreeCstrArray(voikko_langs); - return 0; + return exists; } static EnchantDict * |