[evolution/gnome-3-24] Bug 773420 - Prevent crash when e_content_editor_get_content() returns NULL



commit da122f2e34744957fbb0b0daf5ec2624e40787c7
Author: Milan Crha <mcrha redhat com>
Date:   Thu May 18 13:00:02 2017 +0200

    Bug 773420 - Prevent crash when e_content_editor_get_content() returns NULL

 src/composer/e-msg-composer.c        |   25 +++++++++++++++++++++++++
 src/e-util/e-html-editor.c           |    1 +
 src/e-util/e-mail-signature-editor.c |    5 +++++
 3 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 4cdfe9d..7f299f5 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -1249,6 +1249,11 @@ composer_build_message (EMsgComposer *composer,
                        E_CONTENT_EDITOR_GET_PROCESSED,
                        NULL, NULL);
 
+               if (!text) {
+                       g_warning ("%s: Failed to retrieve text/plain processed content", G_STRFUNC);
+                       text = g_strdup ("");
+               }
+
                g_byte_array_append (data, (guint8 *) text, strlen (text));
                g_free (text);
 
@@ -1335,6 +1340,11 @@ composer_build_message (EMsgComposer *composer,
                                E_CONTENT_EDITOR_GET_TEXT_HTML |
                                E_CONTENT_EDITOR_GET_INLINE_IMAGES,
                                from_domain, &inline_images_parts);
+
+                       if (!text) {
+                               g_warning ("%s: Failed to retrieve draft content", G_STRFUNC);
+                               text = g_strdup ("");
+                       }
                } else {
                        text = e_content_editor_get_content (
                                cnt_editor,
@@ -1342,6 +1352,11 @@ composer_build_message (EMsgComposer *composer,
                                E_CONTENT_EDITOR_GET_PROCESSED |
                                E_CONTENT_EDITOR_GET_INLINE_IMAGES,
                                from_domain, &inline_images_parts);
+
+                       if (!text) {
+                               g_warning ("%s: Failed to retrieve HTML processed content", G_STRFUNC);
+                               text = g_strdup ("");
+                       }
                }
 
                length = strlen (text);
@@ -5176,6 +5191,11 @@ e_msg_composer_get_raw_message_text_without_signature (EMsgComposer *composer)
                E_CONTENT_EDITOR_GET_EXCLUDE_SIGNATURE,
                NULL, NULL);
 
+       if (!content) {
+               g_warning ("%s: Failed to retrieve content", G_STRFUNC);
+               content = g_strdup ("");
+       }
+
        return g_byte_array_new_take ((guint8 *) content, strlen (content));
 }
 
@@ -5202,6 +5222,11 @@ e_msg_composer_get_raw_message_text (EMsgComposer *composer)
                E_CONTENT_EDITOR_GET_TEXT_PLAIN,
                NULL, NULL);
 
+       if (!content) {
+               g_warning ("%s: Failed to retrieve content", G_STRFUNC);
+               content = g_strdup ("");
+       }
+
        return g_byte_array_new_take ((guint8 *) content, strlen (content));
 }
 
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index 0f76bff..0972fc8 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -1325,6 +1325,7 @@ e_html_editor_save (EHTMLEditor *editor,
                        NULL, NULL);
 
        if (!content || !*content) {
+               g_free (content);
                g_set_error (
                        error, G_IO_ERROR, G_IO_ERROR_FAILED,
                        "Failed to obtain content of editor");
diff --git a/src/e-util/e-mail-signature-editor.c b/src/e-util/e-mail-signature-editor.c
index 711b9fc..6be609f 100644
--- a/src/e-util/e-mail-signature-editor.c
+++ b/src/e-util/e-mail-signature-editor.c
@@ -949,6 +949,11 @@ e_mail_signature_editor_commit (EMailSignatureEditor *window,
                E_CONTENT_EDITOR_GET_BODY,
                NULL, NULL);
 
+       if (!contents) {
+               g_warning ("%s: Failed to retrieve content", G_STRFUNC);
+               contents = g_strdup ("");
+       }
+
        extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
        extension = e_source_get_extension (source, extension_name);
        e_source_mail_signature_set_mime_type (extension, mime_type);


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