From: Sergio Villar Senin Date: Fri, 13 Nov 2009 11:23:16 +0000 (+0100) Subject: Fixed a crash in HTML -> text conversor when the body is empty X-Git-Tag: 3.1.15~6 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=481660de0fbc13e2642582e0b27c29074e63ed17;p=modest Fixed a crash in HTML -> text conversor when the body is empty Fixes NB#146571 --- diff --git a/src/modest-formatter.c b/src/modest-formatter.c index 0328be8..9e89ad9 100644 --- a/src/modest-formatter.c +++ b/src/modest-formatter.c @@ -73,7 +73,7 @@ extract_text (ModestFormatter *self, TnyMimePart *body) { TnyStream *mp_stream; TnyStream *stream; - TnyStream *input_stream; + TnyStream *input_stream = NULL; GtkTextBuffer *buf; GtkTextIter start, end; gchar *text; diff --git a/src/modest-stream-html-to-text.c b/src/modest-stream-html-to-text.c index 4a0f609..17a9ead 100644 --- a/src/modest-stream-html-to-text.c +++ b/src/modest-stream-html-to-text.c @@ -193,12 +193,14 @@ static ssize_t html_to_text_read (TnyStream *self, char *buffer, size_t n) { ModestStreamHtmlToTextPrivate *priv; - gint i; + gint i = 0; priv = MODEST_STREAM_HTML_TO_TEXT_GET_PRIVATE (self); - for (i = 0; (i < n) && ((priv->position + i) < priv->buffer->len) ; i++) - buffer[i] = priv->buffer->str[priv->position + i]; + if (priv->buffer) { + for (i = 0; (i < n) && ((priv->position + i) < priv->buffer->len) ; i++) + buffer[i] = priv->buffer->str[priv->position + i]; + } priv->position += i; @@ -240,7 +242,11 @@ html_to_text_is_eos (TnyStream *self) priv = MODEST_STREAM_HTML_TO_TEXT_GET_PRIVATE(self); - return (priv->position >= (priv->buffer->len - 1)); + /* This could happen if the body is empty */ + if (!priv->buffer) + return TRUE; + else + return (priv->position >= (priv->buffer->len - 1)); }