summaryrefslogtreecommitdiffstats
path: root/lasso/id-ff/profile.c
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-04-30 14:58:20 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-04-30 14:58:20 +0000
commite3bdadf8f7abecbc41490bd74f84e8ec7214cc15 (patch)
tree379a0f41aa0b2e49a2170a642094e1c0133d494d /lasso/id-ff/profile.c
parent7071a9ce9a0ae6f81fd5ba53129064a8b7fb4a4d (diff)
downloadlasso-e3bdadf8f7abecbc41490bd74f84e8ec7214cc15.tar.gz
lasso-e3bdadf8f7abecbc41490bd74f84e8ec7214cc15.tar.xz
lasso-e3bdadf8f7abecbc41490bd74f84e8ec7214cc15.zip
ID-FF 1.2: Fix leaks, reduce code
* id-ff/login.c: * id-ff/logout.c: * id-ff/profile.c: * id-ff/provider.c: * id-ff/server.c: fix leaks by using field setting macros which frees previous values, it also reduce code length sometimes.
Diffstat (limited to 'lasso/id-ff/profile.c')
-rw-r--r--lasso/id-ff/profile.c57
1 files changed, 17 insertions, 40 deletions
diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c
index b616228c..16732fc8 100644
--- a/lasso/id-ff/profile.c
+++ b/lasso/id-ff/profile.c
@@ -312,14 +312,12 @@ lasso_profile_set_response_status(LassoProfile *profile, const char *statusCodeV
if (LASSO_IS_SAMLP_RESPONSE(profile->response)) {
LassoSamlpResponse *response = LASSO_SAMLP_RESPONSE(profile->response);
- if (response->Status) lasso_node_destroy(LASSO_NODE(response->Status));
- response->Status = status;
+ lasso_assign_new_gobject(response->Status, status);
return;
}
if (LASSO_IS_LIB_STATUS_RESPONSE(profile->response)) {
LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(profile->response);
- if (response->Status) lasso_node_destroy(LASSO_NODE(response->Status));
- response->Status = status;
+ lasso_assign_new_gobject(response->Status, status);
return;
}
@@ -330,17 +328,10 @@ lasso_profile_set_response_status(LassoProfile *profile, const char *statusCodeV
void
lasso_profile_clean_msg_info(LassoProfile *profile)
{
- if (profile->msg_url) {
- g_free(profile->msg_url);
- profile->msg_url = NULL;
- }
- if (profile->msg_body) {
- g_free(profile->msg_body);
- profile->msg_body = NULL;
- }
+ lasso_release_string(profile->msg_url);
+ lasso_release_string(profile->msg_body);
}
-
/**
* lasso_profile_set_identity_from_dump:
* @profile: a #LassoProfile
@@ -355,12 +346,10 @@ lasso_profile_set_identity_from_dump(LassoProfile *profile, const gchar *dump)
{
g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
- if (profile->identity) {
- g_object_unref(profile->identity);
- }
- profile->identity = lasso_identity_new_from_dump(dump);
- if (profile->identity == NULL)
+ lasso_assign_new_gobject(profile->identity, lasso_identity_new_from_dump(dump));
+ if (profile->identity == NULL) {
return critical_error(LASSO_PROFILE_ERROR_BAD_IDENTITY_DUMP);
+ }
return 0;
}
@@ -380,10 +369,7 @@ lasso_profile_set_session_from_dump(LassoProfile *profile, const gchar *dump)
{
g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
- if (profile->session) {
- g_object_unref(profile->session);
- }
- profile->session = lasso_session_new_from_dump(dump);
+ lasso_assign_new_gobject(profile->session, lasso_session_new_from_dump(dump));
if (profile->session == NULL)
return critical_error(LASSO_PROFILE_ERROR_BAD_SESSION_DUMP);
@@ -411,10 +397,7 @@ lasso_profile_get_artifact_message(LassoProfile *profile)
void
lasso_profile_set_artifact_message(LassoProfile *profile, char *message)
{
- if (profile->private_data->artifact_message) {
- g_free(profile->private_data->artifact_message);
- }
- profile->private_data->artifact_message = g_strdup(message);
+ lasso_assign_string(profile->private_data->artifact_message, message);
}
/**
@@ -508,11 +491,11 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
if (strcmp((char*)t->name, "Artifact") == 0) {
s = xmlNodeGetContent(t);
- profile->private_data->artifact = g_strdup((char*)s);
+ lasso_assign_string(profile->private_data->artifact, (char*)s);
xmlFree(s);
} else if (strcmp((char*)t->name, "ArtifactMessage") == 0) {
s = xmlNodeGetContent(t);
- profile->private_data->artifact_message = g_strdup((char*)s);
+ lasso_assign_string(profile->private_data->artifact_message, (char*)s);
xmlFree(s);
}
@@ -540,22 +523,16 @@ dispose(GObject *object)
lasso_mem_debug("LassoProfile", "Server", profile->server);
- lasso_server_destroy(profile->server);
- profile->server = NULL;
+ lasso_release_gobject(profile->server);
lasso_mem_debug("LassoProfile", "Identity", profile->identity);
- lasso_identity_destroy(profile->identity);
- profile->identity = NULL;
+ lasso_release_gobject(profile->identity);
lasso_mem_debug("LassoProfile", "Session", profile->session);
- lasso_session_destroy(profile->session);
- profile->session = NULL;
+ lasso_release_gobject(profile->session);
- g_free(profile->private_data->artifact);
- profile->private_data->artifact = NULL;
-
- g_free(profile->private_data->artifact_message);
- profile->private_data->artifact_message = NULL;
+ lasso_release_string(profile->private_data->artifact);
+ lasso_release_string(profile->private_data->artifact_message);
G_OBJECT_CLASS(parent_class)->dispose(G_OBJECT(profile));
}
@@ -564,7 +541,7 @@ static void
finalize(GObject *object)
{
LassoProfile *profile = LASSO_PROFILE(object);
- g_free(profile->private_data);
+ lasso_release(profile->private_data);
G_OBJECT_CLASS(parent_class)->finalize(object);
}