From b18cfdce6f6806ad5d7dd5c48bcdbebbb9e49948 Mon Sep 17 00:00:00 2001 From: Yosef Or Boczko Date: Mon, 12 Aug 2024 20:17:57 +0300 Subject: [PATCH] hspell: Correct usage of g_return_val_if_fail and g_warning Epiphany's commit #70f8362e treats critical warnings as fatal, causing epiphany to crash when hspell_convert_to_iso8859_8 fails instead of just logging a warning. The g_return_val_if_fail macro is intended to validate parameters passed to a function, meaning it should only be used to indicate programmer errors. This commit replace g_return_val_if_fail with g_warning for checking the result of hspell_convert_to_iso8859_8. Fix #394 --- providers/enchant_hspell.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/providers/enchant_hspell.c b/providers/enchant_hspell.c index 4eba74ed..b3edc289 100644 --- a/providers/enchant_hspell.c +++ b/providers/enchant_hspell.c @@ -87,7 +87,10 @@ hspell_dict_check (EnchantDict * me, const char *const word, size_t len) { struct dict_radix *hspell_dict = (struct dict_radix *)me->user_data; char *iso_word = hspell_convert_to_iso8859_8 (me, word, len); - g_return_val_if_fail (iso_word, -1); + if (iso_word == NULL) { + g_warning ("%s: Can't convert word to iso8859-8", __FUNCTION__); + return -1; + } /* check */ int preflen; @@ -108,7 +111,10 @@ hspell_dict_suggest (EnchantDict * me, const char *const word, { struct dict_radix *hspell_dict = (struct dict_radix *)me->user_data; char *iso_word = hspell_convert_to_iso8859_8 (me, word, len); - g_return_val_if_fail (iso_word, NULL); + if (iso_word == NULL) { + g_warning ("%s: Can't convert word to iso8859-8", __FUNCTION__); + return NULL; + } /* get suggestions */ struct corlist cl;