talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 295a5b31fc8a52fe36bc7fdbf9cd554539bce8f5
parent 9625310e58efa172e7147eb2de12319220876c2f
Author: Ricardo Mones <ricardo@mones.org>
Date:   Sun,  9 Mar 2025 18:09:47 +0100

Fix CID 1642812 "resource leak" and other issues

• Compare refs_common.dictionary with the token actually added in
  create_empty_dictionary_list() function from gtkaspell.c

• Simplify initial if/else

• Improve readability of code

Diffstat:
Msrc/prefs_spelling.c | 17++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/prefs_spelling.c b/src/prefs_spelling.c @@ -320,18 +320,17 @@ void prefs_spelling_init(void) prefs_spelling = page; language = g_getenv("LANG"); - if (language == NULL) - language = "en"; - else if (!strcmp(language, "POSIX") || !strcmp(language, "C")) + if (language == NULL || !strcmp(language, "POSIX") || !strcmp(language, "C")) language = "en"; if (!prefs_common.dictionary) - prefs_common.dictionary = g_strdup_printf("%s", - language); - if (!strlen(prefs_common.dictionary) - || !strcmp(prefs_common.dictionary,"(None")) - prefs_common.dictionary = g_strdup_printf("%s", - language); + prefs_common.dictionary = g_strdup_printf("%s", language); + + if (!strlen(prefs_common.dictionary) || !strcmp(prefs_common.dictionary, _("None"))) { + g_free(prefs_common.dictionary); + prefs_common.dictionary = g_strdup_printf("%s", language); + } + if (strcasestr(prefs_common.dictionary,".utf")) *(strcasestr(prefs_common.dictionary,".utf")) = '\0'; if (strstr(prefs_common.dictionary,"@"))