Skip to content

Commit

Permalink
hspell: Correct usage of g_return_val_if_fail and g_warning
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yoseforb committed Aug 13, 2024
1 parent 14e8201 commit b246feb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions providers/enchant_hspell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit b246feb

Please sign in to comment.