[gmime] Fixed logic bug when removing a non-existent header



commit ace7fc96636389595ccc8c4e3988bf2c632cdb87
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Wed Feb 19 08:28:26 2014 -0500

    Fixed logic bug when removing a non-existent header
    
    2014-02-19  Jeffrey Stedfast  <fejj gnome org>
    
        * gmime/gmime-message.c (message_remove_header): Don't clear the
        mime_part header stream unless we actually remove a header.
        (message_write_to_stream): Only add nwritten to the total if we've
        written a MIME-Version header.

 ChangeLog             |    7 +++++++
 gmime/gmime-message.c |   14 +++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bf14df5..01b3e9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-02-19  Jeffrey Stedfast  <fejj gnome org>
+
+       * gmime/gmime-message.c (message_remove_header): Don't clear the
+       mime_part header stream unless we actually remove a header.
+       (message_write_to_stream): Only add nwritten to the total if we've
+       written a MIME-Version header.
+
 2013-12-29  Jeffrey Stedfast  <fejj gnome org>
 
        * gmime/gmime-object.c
diff --git a/gmime/gmime-message.c b/gmime/gmime-message.c
index 3b00ee1..3aa3636 100644
--- a/gmime/gmime-message.c
+++ b/gmime/gmime-message.c
@@ -978,10 +978,14 @@ message_remove_header (GMimeObject *object, const char *header)
                break;
        }
        
-       if (message->mime_part)
-               g_mime_header_list_set_stream (message->mime_part->headers, NULL);
+       if (GMIME_OBJECT_CLASS (parent_class)->remove_header (object, header)) {
+               if (message->mime_part)
+                       g_mime_header_list_set_stream (message->mime_part->headers, NULL);
+               
+               return TRUE;
+       }
        
-       return GMIME_OBJECT_CLASS (parent_class)->remove_header (object, header);
+       return FALSE;
 }
 
 
@@ -1034,9 +1038,9 @@ message_write_to_stream (GMimeObject *object, GMimeStream *stream)
                        if (!g_mime_header_list_get (object->headers, "MIME-Version")) {
                                if ((nwritten = g_mime_stream_write_string (stream, "MIME-Version: 1.0\n")) 
== -1)
                                        return -1;
+                               
+                               total += nwritten;
                        }
-                       
-                       total += nwritten;
                }
                
                if ((nwritten = g_mime_object_write_to_stream (message->mime_part, stream)) == -1)


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