Revision: 250 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=250&view=rev Author: eht16 Date: 2008-10-25 09:09:05 +0000 (Sat, 25 Oct 2008)
Log Message: ----------- Add some error checking and prevent crashes if Enchant doesn't provide any dictionaries.
Modified Paths: -------------- trunk/spellcheck/ChangeLog trunk/spellcheck/src/speller.c
Modified: trunk/spellcheck/ChangeLog =================================================================== --- trunk/spellcheck/ChangeLog 2008-10-23 23:48:27 UTC (rev 249) +++ trunk/spellcheck/ChangeLog 2008-10-25 09:09:05 UTC (rev 250) @@ -1,3 +1,10 @@ +2008-10-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/speller.c: + Add some error checking and prevent crashes if Enchant doesn't + provide any dictionaries. + + 2008-10-17 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/spellcheck.c, src/scplugin.c, src/gui.c, src/speller.c,
Modified: trunk/spellcheck/src/speller.c =================================================================== --- trunk/spellcheck/src/speller.c 2008-10-23 23:48:27 UTC (rev 249) +++ trunk/spellcheck/src/speller.c 2008-10-25 09:09:05 UTC (rev 250) @@ -65,6 +65,8 @@ gchar **suggs; GString *str = g_string_sized_new(256);
+ g_return_val_if_fail(speller_dict != NULL, 0); + /* ignore numbers or words starting with digits */ if (isdigit(*word)) return 0; @@ -154,6 +156,8 @@ gchar *dict_string = NULL; gint suggestions_found = 0;
+ g_return_if_fail(speller_dict != NULL); + enchant_dict_describe(speller_dict, dict_describe, &dict_string);
if (p_sci->has_selection(doc->editor->sci)) @@ -235,9 +239,14 @@ * one in the list if not */ if (! check_default_lang()) { - lang = g_ptr_array_index(sc->dicts, 0); - g_warning("Stored language ('%s') could not be loaded. Falling back to '%s'", - sc->default_language, lang); + if (sc->dicts->len > 0) + { + lang = g_ptr_array_index(sc->dicts, 0); + g_warning("Stored language ('%s') could not be loaded. Falling back to '%s'", + sc->default_language, lang); + } + else + g_warning("Stored language ('%s') could not be loaded.", sc->default_language); }
/* Request new dict object */ @@ -313,6 +322,8 @@
void speller_dict_free_string_list(gchar **tmp_suggs) { + g_return_if_fail(speller_dict != NULL); + enchant_dict_free_string_list(speller_dict, tmp_suggs); }
@@ -325,12 +336,16 @@
gboolean speller_dict_check(const gchar *word) { + g_return_val_if_fail(speller_dict != NULL, FALSE); + return enchant_dict_check(speller_dict, word, -1); }
gchar **speller_dict_suggest(const gchar *word, gsize *n_suggs) { + g_return_val_if_fail(speller_dict != NULL, NULL); + return enchant_dict_suggest(speller_dict, word, -1, n_suggs); }
@@ -347,6 +362,7 @@
void speller_free(void) { - enchant_broker_free_dict(speller_broker, speller_dict); + if (speller_dict != NULL) + enchant_broker_free_dict(speller_broker, speller_dict); enchant_broker_free(speller_broker); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org