[balsa] Do not emit a critical warning



commit 1305a74d0bf3b791b3a1660ee06096eae59a968a
Author: Albrecht Dreß <albrecht dress arcor de>
Date:   Fri Apr 7 20:06:49 2017 -0400

    Do not emit a critical warning
    
        * src/balsa-mime-widget.c (balsa_mime_widget_new_unknown): Do
          not emit a critical warning on the console, e.g. when I select
          an encrypted message, but cancel the decryption.
    
    Signed-off-by: Peter Bloomfield <PeterBloomfield bellsouth net>

 ChangeLog               |    8 ++++++++
 src/balsa-mime-widget.c |   20 ++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8a96a2e..5a311de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-07  Albrecht Dreß
+
+Do not emit a critical warning
+
+       * src/balsa-mime-widget.c (balsa_mime_widget_new_unknown): Do
+         not emit a critical warning on the console, e.g. when I select
+         an encrypted message, but cancel the decryption:
+
 2017-04-02  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Deprecation cleanup
diff --git a/src/balsa-mime-widget.c b/src/balsa-mime-widget.c
index 3375c24..fdd11a9 100644
--- a/src/balsa-mime-widget.c
+++ b/src/balsa-mime-widget.c
@@ -249,7 +249,6 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
         g_ascii_strcasecmp(content_type, "application/octet-stream") == 0)
        && LIBBALSA_IS_MAILBOX_LOCAL(mime_body->message->mailbox)) {
         GError *err = NULL;
-       gpointer buffer;
        GMimeStream *stream = 
             libbalsa_message_body_get_stream(mime_body, &err);
         if(!stream) {
@@ -259,20 +258,25 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
             g_clear_error(&err);
             use_content_type = g_strdup(content_type);
         } else {
+               gpointer buffer;
             ssize_t length = 1024 /* g_mime_stream_length(stream) */ ;
             ssize_t size;
 
-            buffer = g_malloc(length);
+            buffer = g_malloc0(length + 1);
             libbalsa_mime_stream_shared_lock(stream);
             size = g_mime_stream_read(stream, buffer, length);
             libbalsa_mime_stream_shared_unlock(stream);
             g_object_unref(stream);
-            use_content_type = libbalsa_vfs_content_type_of_buffer(buffer, size);
-            if (g_ascii_strncasecmp(use_content_type, "text", 4) == 0
-                && (libbalsa_text_attr_string(buffer) & LIBBALSA_TEXT_HI_BIT)) {
-                /* Hmmm...better stick with application/octet-stream. */
-                g_free(use_content_type);
-                use_content_type = g_strdup("application/octet-stream");
+            if (size != -1) {
+               use_content_type = libbalsa_vfs_content_type_of_buffer(buffer, size);
+                if (g_ascii_strncasecmp(use_content_type, "text", 4) == 0
+                    && (libbalsa_text_attr_string(buffer) & LIBBALSA_TEXT_HI_BIT)) {
+                    /* Hmmm...better stick with application/octet-stream. */
+                    g_free(use_content_type);
+                    use_content_type = g_strdup("application/octet-stream");
+                }
+            } else {
+               use_content_type = g_strdup("application/octet-stream");
             }
             g_free(buffer);
         }


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