From 3c516cb10a9ec929143b7b806bcdc5be491c0924 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 22 Feb 2011 13:54:34 +0100 Subject: Bug #608804 - Some attachments make evolution crash in libical --- modules/calendar/e-cal-attachment-handler.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c index 8fea91ffeb..dfc8f58c34 100644 --- a/modules/calendar/e-cal-attachment-handler.c +++ b/modules/calendar/e-cal-attachment-handler.c @@ -83,7 +83,19 @@ attachment_handler_get_component (EAttachment *attachment) camel_data_wrapper_decode_to_stream_sync (wrapper, stream, NULL, NULL); g_object_unref (stream); - component = e_cal_util_parse_ics_string ((gchar *) buffer->data); + if (buffer->len > 0) { + const gchar *str; + + /* ensure string being null-terminated */ + g_byte_array_append (buffer, (const guint8 *) "", 1); + + str = (const gchar *) buffer->data; + while (*str && g_ascii_isspace (*str)) + str++; + + if (g_ascii_strncasecmp (str, "BEGIN:", 6) == 0) + component = e_cal_util_parse_ics_string (str); + } g_byte_array_free (buffer, TRUE); -- cgit v1.2.3