Bug #672837 - Crash in camel_pop3_engine_command_free
authorMilan Crha <mcrha@redhat.com>
Fri, 31 May 2013 16:47:06 +0000 (18:47 +0200)
committerMilan Crha <mcrha@redhat.com>
Fri, 31 May 2013 16:49:40 +0000 (18:49 +0200)
camel/providers/pop3/camel-pop3-engine.c
camel/providers/pop3/camel-pop3-store.c

index 44aa4c3..fd66cd9 100644 (file)
@@ -458,6 +458,8 @@ void
 camel_pop3_engine_command_free (CamelPOP3Engine *pe,
                                 CamelPOP3Command *pc)
 {
+       g_return_if_fail (pc != NULL);
+
        if (pe && pe->current != pc)
                g_queue_remove (&pe->done, pc);
        g_free (pc->error_str);
index 8890c47..e5d2d1d 100644 (file)
@@ -569,14 +569,16 @@ pop3_store_disconnect_sync (CamelService *service,
 
                pop3_engine = camel_pop3_store_ref_engine (store);
 
-               pc = camel_pop3_engine_command_new (
-                       pop3_engine, 0, NULL, NULL,
-                       cancellable, error, "QUIT\r\n");
-               while (camel_pop3_engine_iterate (pop3_engine, NULL, cancellable, NULL) > 0)
-                       ;
-               camel_pop3_engine_command_free (pop3_engine, pc);
-
-               g_clear_object (&pop3_engine);
+               if (pop3_engine) {
+                       pc = camel_pop3_engine_command_new (
+                               pop3_engine, 0, NULL, NULL,
+                               cancellable, error, "QUIT\r\n");
+                       while (camel_pop3_engine_iterate (pop3_engine, NULL, cancellable, NULL) > 0)
+                               ;
+                       camel_pop3_engine_command_free (pop3_engine, pc);
+
+                       g_clear_object (&pop3_engine);
+               }
        }
 
        /* Chain up to parent's disconnect() method. */