From bcd0f3b0d90dae28135b9a82ff42f8843485fd35 Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Thu, 10 Jul 2014 10:09:48 +0200 Subject: 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 file changed, 15 insertions(+), 9 deletions(-) diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c index 5262dec41c..03d9cb7a32 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 ( -- cgit v1.2.3