[evolution-data-server] EDS: memory leak fixes



commit a62360e74d0c153dce98bcf6d68a6b460efd1ca2
Author: Patrick Ohly <patrick ohly intel com>
Date:   Wed Mar 7 16:07:33 2012 +0000

    EDS: memory leak fixes
    
    All of these leaks were found with valgrind when testing
    in combination with SyncEvolution. The fixed code passes
    the same tests without issues (in particular no double frees).
    
    The only non-obvious leak is the one of "muid" after
    e_gdbus_cal_call_create_object_sync() apparently a string
    is returned even if the call itself fails.

 addressbook/backends/file/e-book-backend-file.c |    7 +++++--
 addressbook/libebook/e-contact.c                |    2 ++
 calendar/libecal/e-cal.c                        |    1 +
 3 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 2550d76..9c5344e 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -256,6 +256,7 @@ check_remove_uri_for_field (EContact *old_contact,
 	}
 
 	e_contact_photo_free (old_photo);
+	e_contact_photo_free (new_photo);
 
 	return uri;
 }
@@ -565,14 +566,15 @@ maybe_transform_vcard_field_for_photo (EBookBackendFile *bf,
 		 * if not then we do nothing
 		 */
 		if (!is_backend_owned_uri (bf, photo->data.uri))
-			return status;
+			goto done;
 
 		/* Now check if the uri is changed from the BDB copy
 		 */
 		uid = e_contact_get_const (contact, E_CONTACT_UID);
 		if (uid == NULL) {
 			g_propagate_error (error, EDB_ERROR_EX (OTHER_ERROR, _("No UID in the contact")));
-			return STATUS_ERROR;
+			status = STATUS_ERROR;
+			goto done;
 		}
 
 		if (old_contact)
@@ -635,6 +637,7 @@ maybe_transform_vcard_field_for_photo (EBookBackendFile *bf,
 
 	}
 
+ done:
 	e_contact_photo_free (photo);
 
 	return status;
diff --git a/addressbook/libebook/e-contact.c b/addressbook/libebook/e-contact.c
index 292f199..d49c648 100644
--- a/addressbook/libebook/e-contact.c
+++ b/addressbook/libebook/e-contact.c
@@ -1733,6 +1733,7 @@ e_contact_set (EContact *contact,
 
 	/* set the cached slot to NULL so we'll re-get the new string
 	 * if e_contact_get_const is called again */
+        g_free (contact->priv->cached_strings[field_id]);
 	contact->priv->cached_strings[field_id] = NULL;
 
 	g_object_set (contact,
@@ -2343,6 +2344,7 @@ e_contact_photo_make_inline (EContactPhoto *photo,
 		success = TRUE;
 	}
 
+	g_free (filename);
 	return success;
 }
 
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index b4f43de..c2ab5c9 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -3931,6 +3931,7 @@ e_cal_create_object (ECal *ecal,
 
 	obj = icalcomponent_as_ical_string_r (icalcomp);
 	if (!e_gdbus_cal_call_create_object_sync (priv->gdbus_cal, e_util_ensure_gdbus_string (obj, &gdbus_obj), &muid, NULL, error)) {
+		g_free (muid);
 		g_free (obj);
 		g_free (gdbus_obj);
 



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