[evolution-data-server/imapx-extensible: 4/6] CamelIMAPXServer: do not hide possible programming issue



commit b90d2871eebf6e693cbb34d986816d9122906f0c
Author: Christian Hilberg <chilberg src gnome org>
Date:   Thu Jun 14 16:56:46 2012 +0200

    CamelIMAPXServer: do not hide possible programming issue
    
    * 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 |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c
index 0c7568c..20abae1 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -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;



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