summaryrefslogtreecommitdiff
path: root/providers
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2017-11-24 10:34:01 +0100
committerJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2017-11-24 10:35:02 +0100
commit5d1257041e6e84b16ee9adc8d1ec6495adc26103 (patch)
tree2606ac8660ca7f6e7dba8c86cc1c6e5dc83ecaac /providers
parent9889e6350eb645feca2b0c061f719ca4188984d5 (diff)
downloadenchant-5d1257041e6e84b16ee9adc8d1ec6495adc26103.tar.gz
voikko: Avoid crashing when there are no languages
voikko_provider_list_dicts returned NULL in this case. Fix this and use voikkoListSupportedSpellingLanguages directly, which always returns a valid pointer and also avoids copying.
Diffstat (limited to 'providers')
-rw-r--r--providers/enchant_voikko.c15
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 *