Warn and fail rather than miserably crashing when format string in
authorwwp <subscript@free.fr>
Sat, 18 Aug 2018 07:56:41 +0000 (09:56 +0200)
committerwwp <subscript@free.fr>
Sat, 18 Aug 2018 07:56:41 +0000 (09:56 +0200)
faulty.

src/account.c

index cf28983..e73a012 100644 (file)
@@ -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;
 }