# HG changeset patch # User Mikael Berthe # Date 1341429343 -7200 # Node ID db8ec238cd2cf83560ba42a8a21927819dafa0ee # Parent 99db5d4ed047b3dbe54727c1df311531f611f31f Fix segfault when spell checking is enabled and spell_lang is not set. This patch fixes issue #93. diff -r 99db5d4ed047 -r db8ec238cd2c mcabber/mcabber/screen.c --- a/mcabber/mcabber/screen.c Thu Mar 01 20:18:00 2012 +0100 +++ b/mcabber/mcabber/screen.c Wed Jul 04 21:15:43 2012 +0200 @@ -43,10 +43,10 @@ #ifdef WITH_ENCHANT # include -#endif - -#ifdef WITH_ASPELL -# include +#else +# ifdef WITH_ASPELL +# include +# endif #endif #include "screen.h" @@ -4365,9 +4365,6 @@ spell_checker = NULL; spell_broker = NULL; } - - spell_broker = enchant_broker_init(); - spell_checker = enchant_broker_request_dict(spell_broker, spell_lang); #endif #ifdef WITH_ASPELL if (spell_checker) { @@ -4376,9 +4373,23 @@ spell_checker = NULL; spell_config = NULL; } - +#endif + + if (!spell_lang) { // Cannot initialize: language not specified + scr_LogPrint(LPRINT_LOGNORM, "Error: Cannot initialize spell checker, language not specified."); + scr_LogPrint(LPRINT_LOGNORM, "Please set the 'spell_lang' variable."); + return; + } + +#ifdef WITH_ENCHANT + spell_broker = enchant_broker_init(); + spell_checker = enchant_broker_request_dict(spell_broker, spell_lang); +#endif + +#ifdef WITH_ASPELL spell_config = new_aspell_config(); - aspell_config_replace(spell_config, "encoding", spell_encoding); + if (spell_encoding) + aspell_config_replace(spell_config, "encoding", spell_encoding); aspell_config_replace(spell_config, "lang", spell_lang); possible_err = new_aspell_speller(spell_config);