Fix leaks

* lasso/id-wsf-2.0/profile.c: release private data object.
 * lasso/saml-2.0/login.c: free NameID content after construction.
 * lasso/xml/tools.c: free algorithm attribute content in
   lasso_node_decrypt_xmlnode.
 * lasso/xml/xml.c: release cutom_element->nodename in destructor.
   remove useless finalize method.
 * tests/basic_tests.c: release xmldoc after use.
 * tests/random_tests.c: free resut of lasso_node_dump.
This commit is contained in:
Benjamin Dauvergne 2010-02-04 00:02:07 +00:00
parent 7aa18e07b1
commit b780bd2376
6 changed files with 17 additions and 15 deletions

View File

@ -723,8 +723,11 @@ dispose(GObject *object)
{
LassoIdWsf2Profile *profile = LASSO_IDWSF2_PROFILE(object);
lasso_release_gobject(profile->private_data->soap_envelope_request);
lasso_release_gobject(profile->private_data->soap_envelope_response);
if (profile->private_data) {
lasso_release_gobject(profile->private_data->soap_envelope_request);
lasso_release_gobject(profile->private_data->soap_envelope_response);
}
lasso_release(profile->private_data);
G_OBJECT_CLASS(parent_class)->dispose(object);
}

View File

@ -684,8 +684,10 @@ lasso_saml20_login_build_assertion(LassoLogin *login,
/* TRANSIENT */
if (!name_id_policy || g_strcmp0(name_id_policy->Format,
LASSO_SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT) == 0) {
name_id = (LassoSaml2NameID*)lasso_saml2_name_id_new_with_string(
lasso_build_unique_id(32));
char *id = lasso_build_unique_id(32);
name_id = (LassoSaml2NameID*)lasso_saml2_name_id_new_with_string(id);
lasso_release_string(id);
lasso_assign_string(name_id->NameQualifier,
lasso_provider_get_sp_name_qualifier(&profile->server->parent));
lasso_assign_string(name_id->Format, LASSO_SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT);

View File

@ -1338,7 +1338,7 @@ lasso_node_decrypt_xmlnode(xmlNode* encrypted_element,
xmlNodePtr encrypted_data_node = NULL;
xmlNodePtr encrypted_key_node = NULL;
xmlNodePtr encryption_method_node = NULL;
char *algorithm = NULL;
xmlChar *algorithm = NULL;
xmlSecKeyDataId key_type;
GList *i = NULL;
int rc = LASSO_DS_ERROR_DECRYPTION_FAILED;
@ -1360,14 +1360,14 @@ lasso_node_decrypt_xmlnode(xmlNode* encrypted_element,
message(G_LOG_LEVEL_WARNING, "No EncryptionMethod node in EncryptedData");
goto cleanup;
}
algorithm = (char*)xmlGetProp(encryption_method_node, (xmlChar *)"Algorithm");
algorithm = xmlGetProp(encryption_method_node, (xmlChar *)"Algorithm");
if (algorithm == NULL) {
message(G_LOG_LEVEL_WARNING, "No EncryptionMethod");
goto cleanup;
}
if (strstr(algorithm , "#aes")) {
if (strstr((char*)algorithm , "#aes")) {
key_type = xmlSecKeyDataAesId;
} else if (strstr(algorithm , "des")) {
} else if (strstr((char*)algorithm , "des")) {
key_type = xmlSecKeyDataDesId;
} else {
message(G_LOG_LEVEL_WARNING, "Unknown EncryptionMethod");
@ -1470,6 +1470,7 @@ cleanup:
lasso_release_doc(doc);
lasso_release_doc(doc2);
lasso_release_gobject(decrypted_node);
lasso_release_xml_string(algorithm);
return rc;
}

View File

@ -825,6 +825,7 @@ _lasso_node_free_custom_element(struct _CustomElement *custom_element)
{
lasso_release_string(custom_element->prefix);
lasso_release_string(custom_element->href);
lasso_release_string(custom_element->nodename);
lasso_release(custom_element);
}
@ -1476,12 +1477,6 @@ lasso_node_dispose(GObject *object)
parent_class->dispose(object);
}
static void
lasso_node_finalize(GObject *object)
{
parent_class->finalize(object);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@ -1509,7 +1504,6 @@ class_init(LassoNodeClass *class)
/* override */
gobject_class->dispose = lasso_node_dispose;
gobject_class->finalize = lasso_node_finalize;
original_xmlnode_quark = g_quark_from_static_string("lasso_original_xmlnode");
custom_element_quark = g_quark_from_static_string("lasso_custom_element");

View File

@ -1873,6 +1873,7 @@ START_TEST(test10_test_alldumps)
node = lasso_node_new_from_xmlNode(xmlDocGetRootElement(xmldoc));
fail_unless (LASSO_IS_SAML2_ENCRYPTED_ELEMENT (node), "Parsing of %s did not return a saml2:EncryptedElement, %s", *iter);
g_object_unref(node);
lasso_release_doc(xmldoc);
++iter;
}
}

View File

@ -204,6 +204,7 @@ START_TEST(test04_node_new_from_dump)
dump = lasso_node_dump(node);
fail_unless(dump != NULL, "node_dump failed");
g_object_unref(node);
g_free(dump);
}
END_TEST