diff options
| author | Damien Laniel <dlaniel@entrouvert.com> | 2008-05-20 18:34:09 +0000 |
|---|---|---|
| committer | Damien Laniel <dlaniel@entrouvert.com> | 2008-05-20 18:34:09 +0000 |
| commit | eb2fbc8fc05e021ef718c1582f7de67e4246caf2 (patch) | |
| tree | 13ed3fc7e02c4b3cbe771898a4d97ee2d884c291 | |
| parent | c9a8f041ab03a83439f39e61ea39b46b162cf257 (diff) | |
| download | lasso-eb2fbc8fc05e021ef718c1582f7de67e4246caf2.tar.gz lasso-eb2fbc8fc05e021ef718c1582f7de67e4246caf2.tar.xz lasso-eb2fbc8fc05e021ef718c1582f7de67e4246caf2.zip | |
fixed some reference counting and memory management
| -rw-r--r-- | lasso/id-ff/login.c | 4 | ||||
| -rw-r--r-- | lasso/id-ff/profile.c | 39 | ||||
| -rw-r--r-- | lasso/id-ff/server.c | 3 | ||||
| -rw-r--r-- | lasso/id-wsf-2.0/discovery.c | 6 | ||||
| -rw-r--r-- | lasso/id-wsf-2.0/profile.c | 8 | ||||
| -rw-r--r-- | lasso/saml-2.0/login.c | 28 | ||||
| -rw-r--r-- | lasso/xml/id-wsf-2.0/disco_endpoint_context.c | 5 | ||||
| -rw-r--r-- | lasso/xml/id-wsf-2.0/disco_svc_metadata.c | 3 | ||||
| -rw-r--r-- | lasso/xml/id-wsf-2.0/sbf_framework.c | 15 | ||||
| -rw-r--r-- | lasso/xml/id-wsf-2.0/sbf_framework.h | 2 | ||||
| -rw-r--r-- | lasso/xml/soap_envelope.c | 17 |
11 files changed, 92 insertions, 38 deletions
diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c index 6ec44bf7..9705a18c 100644 --- a/lasso/id-ff/login.c +++ b/lasso/id-ff/login.c @@ -2091,15 +2091,19 @@ static void dispose(GObject *object) { LassoLogin *login = LASSO_LOGIN(object); + g_free(login->private_data->soap_request_msg); login->private_data->soap_request_msg = NULL; + if (login->private_data->saml2_assertion) lasso_node_destroy(LASSO_NODE(login->private_data->saml2_assertion)); login->private_data->saml2_assertion = NULL; + #ifdef LASSO_WSF_ENABLED if (login->private_data->resourceId) lasso_node_destroy(LASSO_NODE(login->private_data->resourceId)); login->private_data->resourceId = NULL; + if (login->private_data->encryptedResourceId) lasso_node_destroy(LASSO_NODE(login->private_data->encryptedResourceId)); login->private_data->encryptedResourceId = NULL; diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c index 8d4733b9..db370ae3 100644 --- a/lasso/id-ff/profile.c +++ b/lasso/id-ff/profile.c @@ -505,12 +505,51 @@ dispose(GObject *object) lasso_server_destroy(profile->server); profile->server = NULL; + + if (profile->request) { + lasso_node_destroy(profile->request); + profile->request = NULL; + } + + if (profile->response) { + lasso_node_destroy(profile->response); + profile->response = NULL; + } + + if (profile->nameIdentifier) { + lasso_node_destroy(profile->nameIdentifier); + profile->nameIdentifier = NULL; + } + + if (profile->remote_providerID) { + g_free(profile->remote_providerID); + profile->remote_providerID = NULL; + } + + 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; + } + + if (profile->msg_relayState) { + g_free(profile->msg_relayState); + profile->msg_relayState = NULL; + } + lasso_identity_destroy(profile->identity); profile->identity = NULL; + lasso_session_destroy(profile->session); profile->session = NULL; + g_free(profile->private_data->artifact); profile->private_data->artifact = NULL; + g_free(profile->private_data->artifact_message); profile->private_data->artifact_message = NULL; diff --git a/lasso/id-ff/server.c b/lasso/id-ff/server.c index e32b16f1..68df89da 100644 --- a/lasso/id-ff/server.c +++ b/lasso/id-ff/server.c @@ -157,7 +157,7 @@ lasso_server_get_svc_metadatas(LassoServer *server) { g_return_val_if_fail(LASSO_IS_SERVER(server), NULL); - return server->private_data->svc_metadatas; + return g_list_copy(server->private_data->svc_metadatas); } GList * @@ -579,6 +579,7 @@ dispose(GObject *object) /* } */ if (server->private_data->svc_metadatas != NULL) { + g_list_foreach(server->private_data->svc_metadatas, (GFunc)g_object_unref, NULL); g_list_free(server->private_data->svc_metadatas); server->private_data->svc_metadatas = NULL; } diff --git a/lasso/id-wsf-2.0/discovery.c b/lasso/id-wsf-2.0/discovery.c index 2d0ef19a..ed226ebc 100644 --- a/lasso/id-wsf-2.0/discovery.c +++ b/lasso/id-wsf-2.0/discovery.c @@ -95,6 +95,7 @@ lasso_idwsf2_discovery_metadata_register_self(LassoIdWsf2Discovery *discovery, gchar *provider_id; LassoIdWsf2DiscoSvcMetadata *metadata; char unique_id[33]; + char *new_svcMDID; g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), NULL); g_return_val_if_fail(service_type != NULL && service_type[0] != '\0', NULL); @@ -119,7 +120,10 @@ lasso_idwsf2_discovery_metadata_register_self(LassoIdWsf2Discovery *discovery, /* Add the metadata into the server object */ lasso_server_add_svc_metadata(LASSO_PROFILE(profile)->server, metadata); - return g_strdup(metadata->svcMDID); + new_svcMDID = g_strdup(metadata->svcMDID); + g_object_unref(metadata); + + return new_svcMDID; } gint diff --git a/lasso/id-wsf-2.0/profile.c b/lasso/id-wsf-2.0/profile.c index 78b857c5..ee20e75c 100644 --- a/lasso/id-wsf-2.0/profile.c +++ b/lasso/id-wsf-2.0/profile.c @@ -142,9 +142,8 @@ lasso_idwsf2_profile_process_soap_request_msg(LassoIdWsf2Profile *profile, const g_return_val_if_fail(message != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); /* Get soap request */ - envelope = lasso_soap_envelope_new_from_message(message); - - profile->soap_envelope_request = envelope; + profile->soap_envelope_request = lasso_soap_envelope_new_from_message(message); + envelope = profile->soap_envelope_request; if (LASSO_PROFILE(profile)->nameIdentifier != NULL) { lasso_node_destroy(LASSO_PROFILE(profile)->nameIdentifier); @@ -202,9 +201,8 @@ lasso_idwsf2_profile_process_soap_request_msg(LassoIdWsf2Profile *profile, const } /* Set soap response */ - envelope = lasso_idwsf2_profile_build_soap_envelope(NULL, + profile->soap_envelope_response = lasso_idwsf2_profile_build_soap_envelope(NULL, LASSO_PROVIDER(LASSO_PROFILE(profile)->server)->ProviderID); - profile->soap_envelope_response = envelope; return res; } diff --git a/lasso/saml-2.0/login.c b/lasso/saml-2.0/login.c index 7ee9cf80..0fff159a 100644 --- a/lasso/saml-2.0/login.c +++ b/lasso/saml-2.0/login.c @@ -663,20 +663,20 @@ lasso_saml20_login_assertion_add_discovery(LassoLogin *login, LassoSaml2Assertio svcMD = svcMDs->data; if (svcMD == NULL || svcMD->ServiceContext == NULL || svcMD->ServiceContext->data == NULL) { + g_list_free(svcMDs); return; } /* Build EndpointReference */ epr = lasso_wsa_endpoint_reference_new(); - service_context = LASSO_IDWSF2_DISCO_SERVICE_CONTEXT(svcMD->ServiceContext->data); - endpoint_context = LASSO_IDWSF2_DISCO_ENDPOINT_CONTEXT( - service_context->EndpointContext->data); + service_context = svcMD->ServiceContext->data; + endpoint_context = service_context->EndpointContext->data; epr->Address = lasso_wsa_attributed_uri_new_with_string( (gchar*)endpoint_context->Address->data); - metadata = LASSO_WSA_METADATA(lasso_wsa_metadata_new()); + metadata = lasso_wsa_metadata_new(); /* Abstract */ metadata->any = g_list_append(metadata->any, @@ -691,18 +691,17 @@ lasso_saml20_login_assertion_add_discovery(LassoLogin *login, LassoSaml2Assertio /* Framework */ if (endpoint_context->Framework != NULL) { metadata->any = g_list_append(metadata->any, - g_object_ref((GObject*)endpoint_context->Framework->data)); + g_object_ref(endpoint_context->Framework->data)); } /* Identity token */ assertion_identity_token = LASSO_SAML2_ASSERTION(lasso_saml2_assertion_new()); assertion_identity_token->Subject = g_object_ref(assertion->Subject); - sec_token = LASSO_IDWSF2_SEC_TOKEN(lasso_idwsf2_sec_token_new()); + sec_token = lasso_idwsf2_sec_token_new(); sec_token->any = LASSO_NODE(assertion_identity_token); - security_context = LASSO_IDWSF2_DISCO_SECURITY_CONTEXT( - lasso_idwsf2_disco_security_context_new()); + security_context = lasso_idwsf2_disco_security_context_new(); security_context->SecurityMechID = g_list_append( security_context->SecurityMechID, g_strdup(LASSO_SECURITY_MECH_TLS_BEARER)); security_context->Token = g_list_append(security_context->Token, sec_token); @@ -713,21 +712,23 @@ lasso_saml20_login_assertion_add_discovery(LassoLogin *login, LassoSaml2Assertio epr->Metadata = metadata; /* Add the EPR to the assertion as a SAML attribute */ - attributeValue = LASSO_SAML2_ATTRIBUTE_VALUE(lasso_saml2_attribute_value_new()); + attributeValue = lasso_saml2_attribute_value_new(); attributeValue->any = g_list_append(attributeValue->any, epr); attribute = LASSO_SAML2_ATTRIBUTE(lasso_saml2_attribute_new()); attribute->Name = g_strdup(LASSO_SAML2_ATTRIBUTE_NAME_EPR); attribute->NameFormat = g_strdup(LASSO_SAML2_ATTRIBUTE_NAME_FORMAT_URI); - attribute->AttributeValue = g_list_append(attribute->AttributeValue, - attributeValue); + attribute->AttributeValue = g_list_append(attribute->AttributeValue, attributeValue); attributeStatement = LASSO_SAML2_ATTRIBUTE_STATEMENT(lasso_saml2_attribute_statement_new()); - attributeStatement->Attribute = g_list_append( - attributeStatement->Attribute, attribute); + attributeStatement->Attribute = g_list_append(attributeStatement->Attribute, attribute); assertion->AttributeStatement = g_list_append(assertion->AttributeStatement, attributeStatement); + + /* Free resources */ + g_list_foreach(svcMDs, (GFunc)lasso_node_destroy, NULL); + g_list_free(svcMDs); #endif } @@ -840,6 +841,7 @@ lasso_saml20_login_build_assertion(LassoLogin *login, provider->private_data->encryption_sym_key_type)); if (encrypted_element != NULL) { assertion->Subject->EncryptedID = encrypted_element; + g_object_unref(assertion->Subject->NameID); assertion->Subject->NameID = NULL; } } diff --git a/lasso/xml/id-wsf-2.0/disco_endpoint_context.c b/lasso/xml/id-wsf-2.0/disco_endpoint_context.c index e7aa73cd..f28a279f 100644 --- a/lasso/xml/id-wsf-2.0/disco_endpoint_context.c +++ b/lasso/xml/id-wsf-2.0/disco_endpoint_context.c @@ -132,14 +132,11 @@ LassoIdWsf2DiscoEndpointContext* lasso_idwsf2_disco_endpoint_context_new_full(const gchar *address) { LassoIdWsf2DiscoEndpointContext *context; - LassoIdWsf2SbfFramework *sbf_framework; context = lasso_idwsf2_disco_endpoint_context_new(); context->Address = g_list_append(NULL, g_strdup(address)); - sbf_framework = lasso_idwsf2_sbf_framework_new(); - sbf_framework->version = g_strdup("2.0"); - context->Framework = g_list_append(NULL, sbf_framework); + context->Framework = g_list_append(NULL, lasso_idwsf2_sbf_framework_new_full("2.0")); return context; } diff --git a/lasso/xml/id-wsf-2.0/disco_svc_metadata.c b/lasso/xml/id-wsf-2.0/disco_svc_metadata.c index c09b3d5d..5116d3ed 100644 --- a/lasso/xml/id-wsf-2.0/disco_svc_metadata.c +++ b/lasso/xml/id-wsf-2.0/disco_svc_metadata.c @@ -136,7 +136,7 @@ lasso_idwsf2_disco_svc_metadata_new_full(const gchar *service_type, const gchar LassoIdWsf2DiscoSvcMetadata *metadata; LassoIdWsf2DiscoEndpointContext *endpoint_context; - metadata = lasso_idwsf2_disco_svc_metadata_new(); + metadata = g_object_new(LASSO_TYPE_IDWSF2_DISCO_SVC_METADATA, NULL); metadata->Abstract = g_strdup(abstract); metadata->ProviderID = g_strdup(provider_id); @@ -144,6 +144,7 @@ lasso_idwsf2_disco_svc_metadata_new_full(const gchar *service_type, const gchar endpoint_context = lasso_idwsf2_disco_endpoint_context_new_full(soap_endpoint); metadata->ServiceContext = g_list_append(NULL, lasso_idwsf2_disco_service_context_new_full(service_type, endpoint_context)); + g_object_unref(endpoint_context); return metadata; } diff --git a/lasso/xml/id-wsf-2.0/sbf_framework.c b/lasso/xml/id-wsf-2.0/sbf_framework.c index ac193c1a..6490b35d 100644 --- a/lasso/xml/id-wsf-2.0/sbf_framework.c +++ b/lasso/xml/id-wsf-2.0/sbf_framework.c @@ -66,8 +66,7 @@ static void instance_init(LassoIdWsf2SbfFramework *node) { node->version = NULL; - node->attributes = g_hash_table_new_full( - g_str_hash, g_str_equal, g_free, g_free); + node->attributes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); } static void @@ -118,3 +117,15 @@ lasso_idwsf2_sbf_framework_new() { return g_object_new(LASSO_TYPE_IDWSF2_SBF_FRAMEWORK, NULL); } + +LassoIdWsf2SbfFramework* +lasso_idwsf2_sbf_framework_new_full(const char *version) +{ + LassoIdWsf2SbfFramework* framework; + + framework = g_object_new(LASSO_TYPE_IDWSF2_SBF_FRAMEWORK, NULL); + + framework->version = g_strdup(version); + + return framework; +} diff --git a/lasso/xml/id-wsf-2.0/sbf_framework.h b/lasso/xml/id-wsf-2.0/sbf_framework.h index 746471a6..c246e97b 100644 --- a/lasso/xml/id-wsf-2.0/sbf_framework.h +++ b/lasso/xml/id-wsf-2.0/sbf_framework.h @@ -73,7 +73,7 @@ struct _LassoIdWsf2SbfFrameworkClass { LASSO_EXPORT GType lasso_idwsf2_sbf_framework_get_type(void); LASSO_EXPORT LassoIdWsf2SbfFramework* lasso_idwsf2_sbf_framework_new(void); - +LASSO_EXPORT LassoIdWsf2SbfFramework* lasso_idwsf2_sbf_framework_new_full(const char *version); #ifdef __cplusplus } diff --git a/lasso/xml/soap_envelope.c b/lasso/xml/soap_envelope.c index ea06eac1..e855bac3 100644 --- a/lasso/xml/soap_envelope.c +++ b/lasso/xml/soap_envelope.c @@ -89,26 +89,23 @@ lasso_soap_envelope_get_type() LassoSoapEnvelope* lasso_soap_envelope_new(LassoSoapBody *body) { - LassoSoapEnvelope *node; + LassoSoapEnvelope *envelope; - node = g_object_new(LASSO_TYPE_SOAP_ENVELOPE, NULL); + envelope = g_object_new(LASSO_TYPE_SOAP_ENVELOPE, NULL); - node->Body = body; + envelope->Body = body; - return node; + return envelope; } LassoSoapEnvelope* lasso_soap_envelope_new_from_message(const gchar *message) { - LassoSoapEnvelope *node; + LassoSoapEnvelope *envelope; g_return_val_if_fail(message != NULL, NULL); - node = g_object_new(LASSO_TYPE_SOAP_ENVELOPE, NULL); - lasso_node_init_from_message(LASSO_NODE(node), message); + envelope = LASSO_SOAP_ENVELOPE(lasso_node_new_from_dump(message)); - node = LASSO_SOAP_ENVELOPE(lasso_node_new_from_dump(message)); - - return node; + return envelope; } |
