Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 2015:db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
This patch fixes issue #93.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 04 Jul 2012 21:15:43 +0200 |
parents | 8dc418af3e72 |
children | 7b5bd6ad83b4 |
comparison
equal
deleted
inserted
replaced
2014:99db5d4ed047 | 2015:db8ec238cd2c |
---|---|
41 # include <langinfo.h> | 41 # include <langinfo.h> |
42 #endif | 42 #endif |
43 | 43 |
44 #ifdef WITH_ENCHANT | 44 #ifdef WITH_ENCHANT |
45 # include <enchant.h> | 45 # include <enchant.h> |
46 #endif | 46 #else |
47 | 47 # ifdef WITH_ASPELL |
48 #ifdef WITH_ASPELL | 48 # include <aspell.h> |
49 # include <aspell.h> | 49 # endif |
50 #endif | 50 #endif |
51 | 51 |
52 #include "screen.h" | 52 #include "screen.h" |
53 #include "utf8.h" | 53 #include "utf8.h" |
54 #include "hbuf.h" | 54 #include "hbuf.h" |
4363 enchant_broker_free_dict(spell_broker, spell_checker); | 4363 enchant_broker_free_dict(spell_broker, spell_checker); |
4364 enchant_broker_free(spell_broker); | 4364 enchant_broker_free(spell_broker); |
4365 spell_checker = NULL; | 4365 spell_checker = NULL; |
4366 spell_broker = NULL; | 4366 spell_broker = NULL; |
4367 } | 4367 } |
4368 | |
4369 spell_broker = enchant_broker_init(); | |
4370 spell_checker = enchant_broker_request_dict(spell_broker, spell_lang); | |
4371 #endif | 4368 #endif |
4372 #ifdef WITH_ASPELL | 4369 #ifdef WITH_ASPELL |
4373 if (spell_checker) { | 4370 if (spell_checker) { |
4374 delete_aspell_speller(spell_checker); | 4371 delete_aspell_speller(spell_checker); |
4375 delete_aspell_config(spell_config); | 4372 delete_aspell_config(spell_config); |
4376 spell_checker = NULL; | 4373 spell_checker = NULL; |
4377 spell_config = NULL; | 4374 spell_config = NULL; |
4378 } | 4375 } |
4379 | 4376 #endif |
4377 | |
4378 if (!spell_lang) { // Cannot initialize: language not specified | |
4379 scr_LogPrint(LPRINT_LOGNORM, "Error: Cannot initialize spell checker, language not specified."); | |
4380 scr_LogPrint(LPRINT_LOGNORM, "Please set the 'spell_lang' variable."); | |
4381 return; | |
4382 } | |
4383 | |
4384 #ifdef WITH_ENCHANT | |
4385 spell_broker = enchant_broker_init(); | |
4386 spell_checker = enchant_broker_request_dict(spell_broker, spell_lang); | |
4387 #endif | |
4388 | |
4389 #ifdef WITH_ASPELL | |
4380 spell_config = new_aspell_config(); | 4390 spell_config = new_aspell_config(); |
4381 aspell_config_replace(spell_config, "encoding", spell_encoding); | 4391 if (spell_encoding) |
4392 aspell_config_replace(spell_config, "encoding", spell_encoding); | |
4382 aspell_config_replace(spell_config, "lang", spell_lang); | 4393 aspell_config_replace(spell_config, "lang", spell_lang); |
4383 possible_err = new_aspell_speller(spell_config); | 4394 possible_err = new_aspell_speller(spell_config); |
4384 | 4395 |
4385 if (aspell_error_number(possible_err) != 0) { | 4396 if (aspell_error_number(possible_err) != 0) { |
4386 spell_checker = NULL; | 4397 spell_checker = NULL; |