Don't crash if the str argument is NULL.
authorJeffrey Stedfast <fejj@novell.com>
Wed, 25 Jun 2008 21:58:02 +0000 (21:58 +0000)
committerJeffrey Stedfast <fejj@src.gnome.org>
Wed, 25 Jun 2008 21:58:02 +0000 (21:58 +0000)
2008-06-25  Jeffrey Stedfast  <fejj@novell.com>

* camel-mime-utils.c (camel_header_decode_date): Don't crash if
the str argument is NULL.

* camel-folder-summary.c (message_info_new_from_header): Don't
allow ourselves to pass NULL as the str argument to
camel_header_decode_date().

svn path=/trunk/; revision=9045

camel/ChangeLog
camel/camel-folder-summary.c
camel/camel-mime-utils.c

index 37dc024..a06c348 100644 (file)
@@ -1,3 +1,12 @@
+2008-06-25  Jeffrey Stedfast  <fejj@novell.com>
+
+       * camel-mime-utils.c (camel_header_decode_date): Don't crash if
+       the str argument is NULL.
+
+       * camel-folder-summary.c (message_info_new_from_header): Don't
+       allow ourselves to pass NULL as the str argument to
+       camel_header_decode_date().
+
 2008-06-21  Jeffrey Stedfast  <fejj@novell.com>
 
        * broken-date-parser.[c,h]: Removed, more-or-less moved into
index 3f119b0..62e81d1 100644 (file)
@@ -1736,16 +1736,15 @@ camel_folder_summary_content_info_new(CamelFolderSummary *s)
 static CamelMessageInfo *
 message_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *h)
 {
+       const char *received, *date, *content, *charset = NULL;
+       struct _camel_header_references *refs, *irt, *scan;
+       char *subject, *from, *to, *cc, *mlist;
+       CamelContentType *ct = NULL;
        CamelMessageInfoBase *mi;
-       const char *received;
        guint8 *digest;
        gsize length;
-       struct _camel_header_references *refs, *irt, *scan;
        char *msgid;
        int count;
-       char *subject, *from, *to, *cc, *mlist;
-       CamelContentType *ct = NULL;
-       const char *content, *charset = NULL;
 
        length = g_checksum_type_get_length (G_CHECKSUM_MD5);
        digest = g_alloca (length);
@@ -1777,7 +1776,12 @@ message_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *h)
        
        mi->user_flags = NULL;
        mi->user_tags = NULL;
-       mi->date_sent = camel_header_decode_date(camel_header_raw_find(&h, "date", NULL), NULL);
+       
+       if ((date = camel_header_raw_find (&h, "date", NULL)))
+               mi->date_sent = camel_header_decode_date (date, NULL);
+       else
+               mi->date_sent = 0;
+       
        received = camel_header_raw_find(&h, "received", NULL);
        if (received)
                received = strrchr(received, ';');
index 81d682c..7bff7a4 100644 (file)
@@ -4175,7 +4175,7 @@ camel_header_decode_date (const char *str, int *tz_offset)
        struct _date_token *token, *tokens;
        time_t date;
        
-       if (!(tokens = datetok (str))) {
+       if (!str || !(tokens = datetok (str))) {
                if (tz_offset)
                        *tz_offset = 0;