[evolution-data-server/gnome-3-8] Avoid a crash in cal_backend_add_cached_timezone().



commit 4fabcb3c68c07c7c384de348d8b8d24491ff1fce
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jul 3 11:40:39 2013 -0400

    Avoid a crash in cal_backend_add_cached_timezone().
    
    Apparently icaltimezone_get_tzid() can sometimes return NULL.  Check for
    NULL before we use it in a hash table lookup, which crashes on NULL keys.
    
    Add a similar check to ECalClient for consistency.
    
    (cherry picked from commit 244003d568113a82628bc74b337274a6e8fee433)

 calendar/libecal/e-cal-client.c       |    9 +++++++--
 calendar/libedata-cal/e-cal-backend.c |    9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index a5615a9..ede024a 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -1216,9 +1216,14 @@ cal_client_add_cached_timezone (ETimezoneCache *cache,
 
        priv = E_CAL_CLIENT_GET_PRIVATE (cache);
 
-       g_mutex_lock (&priv->zone_cache_lock);
-
+       /* XXX Apparently this function can sometimes return NULL.
+        *     I'm not sure when or why that happens, but we can't
+        *     cache the icaltimezone if it has no tzid string. */
        tzid = icaltimezone_get_tzid (zone);
+       if (tzid == NULL)
+               return;
+
+       g_mutex_lock (&priv->zone_cache_lock);
 
        /* Avoid replacing an existing cache entry.  We don't want to
         * invalidate any icaltimezone pointers that may have already
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index f3753f5..4218b45 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -403,9 +403,14 @@ cal_backend_add_cached_timezone (ETimezoneCache *cache,
 
        priv = E_CAL_BACKEND_GET_PRIVATE (cache);
 
-       g_mutex_lock (&priv->zone_cache_lock);
-
+       /* XXX Apparently this function can sometimes return NULL.
+        *     I'm not sure when or why that happens, but we can't
+        *     cache the icaltimezone if it has no tzid string. */
        tzid = icaltimezone_get_tzid (zone);
+       if (tzid == NULL)
+               return;
+
+       g_mutex_lock (&priv->zone_cache_lock);
 
        /* Avoid replacing an existing cache entry.  We don't want to
         * invalidate any icaltimezone pointers that may have already


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