[evolution-rss] Avoid crash when feed formatting is cancelled



commit fc88879852be20917ba1c1923ab77c8b5bc868ed
Author: Milan Crha <mcrha redhat com>
Date:   Wed Oct 10 14:12:42 2018 +0200

    Avoid crash when feed formatting is cancelled
    
    It could happen that the feed formatting routine had been cancelled
    before it had been finished, which could, in some cases, lead to NULL
    dereference and to the crash.
    
    This had been reported downstream as:
    https://bugzilla.redhat.com/show_bug.cgi?id=1624609

 src/e-mail-formatter-evolution-rss.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/src/e-mail-formatter-evolution-rss.c b/src/e-mail-formatter-evolution-rss.c
index afdf6cd..8f14a54 100644
--- a/src/e-mail-formatter-evolution-rss.c
+++ b/src/e-mail-formatter-evolution-rss.c
@@ -244,6 +244,11 @@ emfe_evolution_rss_format (EMailFormatterExtension *extension,
                        strlen(str), NULL, cancellable, NULL);
 #endif
 
+               g_free (str);
+
+               if (g_cancellable_is_cancelled (cancellable))
+                       goto fail;
+
 #if EVOLUTION_VERSION < 31191
                decoded_stream = camel_stream_mem_new ();
 #else
@@ -253,6 +258,11 @@ emfe_evolution_rss_format (EMailFormatterExtension *extension,
                e_mail_formatter_format_text (
                        formatter, part, decoded_stream, cancellable);
 
+               if (g_cancellable_is_cancelled (cancellable)) {
+                       g_clear_object (&decoded_stream);
+                       goto fail;
+               }
+
 #if EVOLUTION_VERSION < 31191
                g_seekable_seek (G_SEEKABLE (decoded_stream), 0, G_SEEK_SET, cancellable, NULL);
 
@@ -265,6 +275,11 @@ emfe_evolution_rss_format (EMailFormatterExtension *extension,
                                G_MEMORY_OUTPUT_STREAM (decoded_stream));
                src = rss_process_feed((gchar *)data, len);
 #endif
+               if (g_cancellable_is_cancelled (cancellable) || !src) {
+                       g_clear_object (&decoded_stream);
+                       g_free (src);
+                       goto fail;
+               }
 #if EVOLUTION_VERSION < 30304
                client = gconf_client_get_default();
 #else
@@ -318,6 +333,8 @@ emfe_evolution_rss_format (EMailFormatterExtension *extension,
                g_free(tstr);
                }
 #endif
+               if (g_cancellable_is_cancelled (cancellable))
+                       goto fail;
        } else {
                GString *content;
                GError *err = NULL;
@@ -360,6 +377,10 @@ emfe_evolution_rss_format (EMailFormatterExtension *extension,
                        }
 #endif
                        g_free (str);
+
+                       if (g_cancellable_is_cancelled (cancellable))
+                               goto fail;
+
                        goto success;
                }
 


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