[evolution] Bug 732891 - Crash under process_elements() at e-html-editor-view.c:5004



commit bcd0f3b0d90dae28135b9a82ff42f8843485fd35
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Jul 10 10:09:48 2014 +0200

    Bug 732891 - Crash under process_elements() at e-html-editor-view.c:5004
    
    Check if the buffer already contains some data before doing some work
    on it.

 e-util/e-html-editor-view.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 5262dec..03d9cb7 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4871,11 +4871,14 @@ process_elements (EHTMLEditorView *view,
                        /* Replace tabs with 8 whitespaces, otherwise they got
                         * replaced by single whitespace */
                        if (strstr (content, "\x9")) {
-                               gchar *start_of_line = g_strrstr_len (
-                                       buffer->str, -1, "\n") + 1;
+                               if (buffer->str && *buffer->str) {
+                                       gchar *start_of_line = g_strrstr_len (
+                                               buffer->str, -1, "\n") + 1;
 
-                               if (start_of_line && *start_of_line)
-                                       char_count = strlen (start_of_line);
+                                       if (start_of_line && *start_of_line)
+                                                       char_count = strlen (start_of_line);
+                               } else
+                                       char_count = 0;
 
                                regex = g_regex_new ("\x9", 0, 0, NULL);
                                tmp = g_regex_replace_eval (
@@ -4998,11 +5001,14 @@ process_elements (EHTMLEditorView *view,
                                /* Replace tabs with 8 whitespaces, otherwise they got
                                 * replaced by single whitespace */
                                if (strstr (content, "\x9")) {
-                                       gchar *start_of_line = g_strrstr_len (
-                                               buffer->str, -1, "\n") + 1;
-
-                                       if (start_of_line && *start_of_line)
-                                               char_count = strlen (start_of_line);
+                                       if (buffer->str && *buffer->str) {
+                                               gchar *start_of_line = g_strrstr_len (
+                                                       buffer->str, -1, "\n") + 1;
+
+                                               if (start_of_line && *start_of_line)
+                                                       char_count = strlen (start_of_line);
+                                       } else
+                                               char_count = 0;
 
                                        regex = g_regex_new ("\x9", 0, 0, NULL);
                                        tmp = g_regex_replace_eval (


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