CamelIMAPXServer: do not hide possible programming issue
authorChristian Hilberg <chilberg@src.gnome.org>
Thu, 14 Jun 2012 14:56:46 +0000 (16:56 +0200)
committerMatthew Barnes <mbarnes@redhat.com>
Tue, 26 Jun 2012 15:20:28 +0000 (11:20 -0400)
* do not free the CamelIMAPXServer private context
  structure at the beginning of imapx_untagged()
  as it is expected to be NULL
* if it isn't, the function got called concurrently
  for the same CamelIMAPXServer instance, in which
  case we need special locking mechanisms anyway
* thanks to Milan Crha for pointing this out

camel/camel-imapx-server.c

index 0c7568c..20abae1 100644 (file)
@@ -1914,8 +1914,12 @@ imapx_untagged (CamelIMAPXServer *is,
        settings = camel_service_get_settings (service);
        priv = CAMEL_IMAPX_SERVER_GET_PRIVATE (is);
 
-       if (priv->context != NULL)
-               g_free (priv->context);
+       /* If priv->context is not NULL here, it basically means that
+        * imapx_untagged() got called concurrently for the same
+        * CamelIMAPXServer instance. Should this ever happen, then
+        * we will need to protect this data structure with locks
+        */
+       g_return_val_if_fail (priv->context == NULL, FALSE);
        priv->context = g_new0 (CamelIMAPXServerUntaggedContext, 1);
 
        priv->context->lsub = FALSE;