From 471063e36fa85cc64b145dec8e32b0647e629ccb Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Sat, 23 Aug 2008 18:20:39 -0400 Subject: [PATCH] Fixing memory leak (if config file has more than 1 resource, the code was allocating and creating username+password strings twice). I'm using 'osyncplugin' utility to help development of plugin. Its a very handy tool that enables to call methods from plugin without loading whole opensync. --- src/gcalendar.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/gcalendar.c b/src/gcalendar.c index 05cddbc..fdbd362 100644 --- a/src/gcalendar.c +++ b/src/gcalendar.c @@ -488,22 +488,28 @@ static void *gc_initialize(OSyncPlugin *plugin, objtype = osync_objtype_sink_get_name(plgdata->sink); /* TODO: get object format */ /* objformat = osync_objtype_sink_get_objformat(plgdata->sink); */ - auth = osync_plugin_config_get_authentication(config); - tmp = osync_plugin_authentication_get_username(auth); - if (!tmp) - goto error_freeplg; - else - if (!(plgdata->username = strdup(tmp))) + if (!plgdata->username) { + auth = osync_plugin_config_get_authentication(config); + tmp = osync_plugin_authentication_get_username(auth); + if (!tmp) goto error_freeplg; + else + if (!(plgdata->username = strdup(tmp))) + goto error_freeplg; - tmp = osync_plugin_authentication_get_password(auth); - if (!tmp) - goto error_freeplg; - else - if (!(plgdata->password = strdup(tmp))) + } + + if (!plgdata->password) { + tmp = osync_plugin_authentication_get_password(auth); + if (!tmp) goto error_freeplg; + else + if (!(plgdata->password = strdup(tmp))) + goto error_freeplg; + } /* TODO: get proxy/calendar title/resources/etc */ + } OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); -- 2.11.4.GIT