talons

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

commit 6406496b93866bb472a221ba93422fdb56c95773
parent e0a319b4b672c592f9824509d948914a4d167a1e
Author: wwp <subscript@free.fr>
Date:   Sat, 18 Aug 2018 09:56:41 +0200

Warn and fail rather than miserably crashing when format string in
faulty.

Diffstat:
Msrc/account.c | 22+++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/account.c b/src/account.c @@ -1977,8 +1977,14 @@ gboolean account_signatures_matchlist_str_found(const gchar *str, const gchar *f item != NULL && !found; item = g_slist_next(item)) { tmp = g_strdup_printf(format, (gchar *)item->data); - found = (strcmp(tmp, str) == 0); - g_free(tmp); + if (tmp) { + found = (strcmp(tmp, str) == 0); + g_free(tmp); + } else { + g_warning("account_signatures_matchlist_str_found: g_strdup_printf failed, check format '%s'", + format); + return FALSE; + } } return found; } @@ -1995,9 +2001,15 @@ gboolean account_signatures_matchlist_nchar_found(const gchar *str, const gchar item != NULL && !found; item = g_slist_next(item)) { tmp = g_strdup_printf(format, (gchar *)item->data); - len = strlen(tmp); - found = (strncmp(tmp, str, len) == 0); - g_free(tmp); + if (tmp) { + len = strlen(tmp); + found = (strncmp(tmp, str, len) == 0); + g_free(tmp); + } else { + g_warning("account_signatures_matchlist_nchar_found: g_strdup_printf failed, check format '%s'", + format); + return FALSE; + } } return found; }