From: <svn...@op...> - 2010-07-10 03:49:44
|
Author: cdfrey Date: Sat Jul 10 05:49:35 2010 New Revision: 6075 URL: http://www.opensync.org/changeset/6075 Log: Fixed memory leaks in environment freeing, and in strings returned from evolution Modified: plugins/evolution2/src/evolution2_sync.c plugins/evolution2/src/evolution2_sync.h Modified: plugins/evolution2/src/evolution2_sync.c ============================================================================== --- plugins/evolution2/src/evolution2_sync.c Sat Jul 10 04:03:28 2010 (r6074) +++ plugins/evolution2/src/evolution2_sync.c Sat Jul 10 05:49:35 2010 (r6075) @@ -40,6 +40,10 @@ { OSyncEvoCalendar *cal = (OSyncEvoCalendar *)data; + if (cal->uri_key) { + free(cal->uri_key); + cal->uri_key = NULL; + } if (cal->calendar) { g_object_unref(cal->calendar); cal->calendar = NULL; @@ -52,6 +56,8 @@ osync_objformat_unref(cal->format); cal->format = NULL; } + + osync_free(cal); } static void free_env(OSyncEvoEnv *env) @@ -79,9 +85,19 @@ GSList *s; for (s = e_source_group_peek_sources (group); s; s = s->next) { ESource *source = E_SOURCE (s->data); - osync_trace(TRACE_INTERNAL, "Comparing source uri %s and %s", e_source_get_uri(source), uri); - if (!strcmp(e_source_get_uri(source), uri)) + + // e_source_get_uri() returns an allocated string + // that we need to free + char *source_uri = e_source_get_uri(source); + osync_trace(TRACE_INTERNAL, "Comparing source uri %s and %s", source_uri, uri); + int cmp = strcmp(source_uri, uri); + g_free(source_uri); + if (!cmp) return source; + + // e_source_peek_name() does not seem to require + // freeing... *sigh* had to read the source code to + // find this out osync_trace(TRACE_INTERNAL, "Comparing source name %s and %s", e_source_peek_name(source), uri); if (!strcmp(e_source_peek_name(source), uri)) return source; Modified: plugins/evolution2/src/evolution2_sync.h ============================================================================== --- plugins/evolution2/src/evolution2_sync.h Sat Jul 10 04:03:28 2010 (r6074) +++ plugins/evolution2/src/evolution2_sync.h Sat Jul 10 05:49:35 2010 (r6075) @@ -44,7 +44,7 @@ typedef struct OSyncEvoCalendar { - const char *uri_key; + char *uri_key; const char *uri; const char *objtype; const char *change_id; |