Fix a potential race in operation_idle_cb().
authorMatthew Barnes <mbarnes@redhat.com>
Wed, 15 Sep 2010 11:56:06 +0000 (07:56 -0400)
committerMatthew Barnes <mbarnes@redhat.com>
Wed, 15 Sep 2010 11:57:01 +0000 (07:57 -0400)
camel/camel-operation.c

index 028ee29..e03702f 100644 (file)
@@ -120,6 +120,11 @@ operation_idle_cb (CamelOperation *operation)
        gchar *msg;
        gint pc;
 
+       /* Keep the operation alive until we emit the signal,
+        * otherwise it might be finalized between unlocking
+        * the mutex and emitting the signal. */
+       g_object_ref (operation);
+
        LOCK ();
 
        msg = operation->priv->status_msg;
@@ -136,6 +141,8 @@ operation_idle_cb (CamelOperation *operation)
                g_free (msg);
        }
 
+       g_object_unref (operation);
+
        return FALSE;
 }