[balsa/gmime3: 64/72] Check for NULL return



commit 17a2c6fbc2cc6ebde8202672cf687b81e88aab35
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Nov 24 18:51:09 2019 -0500

    Check for NULL return
    
    from g_mime_utils_header_decode_date() and g_mime_message_get_date().

 libbalsa/body.c    |  6 ++++--
 libbalsa/message.c | 12 ++++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/libbalsa/body.c b/libbalsa/body.c
index ad9e9ddc6..4d46c76b9 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -118,8 +118,10 @@ libbalsa_message_body_extract_embedded_headers(GMimeMessage* msg)
        ehdr->subject = g_strdup(_("(No subject)"));
 
     datetime = g_mime_message_get_date(msg);
-    ehdr->date = g_date_time_to_unix(datetime);
-    g_date_time_unref(datetime);
+    if (datetime != NULL) {
+        ehdr->date = g_date_time_to_unix(datetime);
+        g_date_time_unref(datetime);
+    }
 
     return ehdr;
 }
diff --git a/libbalsa/message.c b/libbalsa/message.c
index 94de6270c..4bdb7ecdb 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -999,8 +999,10 @@ lb_message_headers_basic_from_gmime(LibBalsaMessageHeaders *headers,
         GDateTime *datetime;
 
         datetime = g_mime_message_get_date(mime_msg);
-        headers->date = g_date_time_to_unix(datetime);
-        g_date_time_unref(datetime);
+        if (datetime != NULL) {
+            headers->date = g_date_time_to_unix(datetime);
+            g_date_time_unref(datetime);
+        }
     }
 
     if (headers->to_list == NULL)
@@ -1234,8 +1236,10 @@ lbmsg_set_header(LibBalsaMessage *message,
         GDateTime *datetime;
 
         datetime = g_mime_utils_header_decode_date(value);
-        message->headers->date = g_date_time_to_unix(datetime);
-        g_date_time_unref(datetime);
+        if (datetime != NULL) {
+            message->headers->date = g_date_time_to_unix(datetime);
+            g_date_time_unref(datetime);
+        }
     } else if ((message->headers->from == NULL) &&
                (g_ascii_strcasecmp(name, "From") == 0)) {
         message->headers->from = internet_address_list_parse(libbalsa_parser_options(), value);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]