Bug #628485 - Accessing freed memory in EContactStore::dispose
authorMilan Crha <mcrha@redhat.com>
Wed, 1 Sep 2010 13:12:15 +0000 (15:12 +0200)
committerMilan Crha <mcrha@redhat.com>
Wed, 1 Sep 2010 13:12:15 +0000 (15:12 +0200)
libedataserverui/e-contact-store.c

index 21fd677..de98248 100644 (file)
@@ -112,8 +112,9 @@ contact_store_dispose (GObject *object)
        for (ii = 0; ii < priv->contact_sources->len; ii++) {
                ContactSource *source;
 
+               /* clear from back, because clear_contact_source can later access freed memory */
                source = &g_array_index (
-                       priv->contact_sources, ContactSource, ii);
+                       priv->contact_sources, ContactSource, priv->contact_sources->len - ii - 1);
 
                clear_contact_source (E_CONTACT_STORE (object), source);
                free_contact_ptrarray (source->contacts);