Remove use of xmlFreeDoc for lasso_release_doc

- bindings/java/wrapper_top.c, bindings/php4/lasso_php4_helper.c,
    bindings/php5/wrapper_source_top.c, bindings/python/wrapper_top.c,
    lasso/id-ff/identity.c, lasso/id-ff/lecp.c, lasso/id-ff/login.c,
    lasso/id-ff/logout.c, lasso/id-ff/name_registration.c,
    lasso/id-ff/profile.c, lasso/id-ff/provider.c, lasso/id-ff/server.c,
    lasso/id-ff/session.c, lasso/id-wsf-2.0/data_service.c,
    lasso/id-wsf/data_service.c, lasso/id-wsf/discovery.c,
    lasso/id-wsf/wsf_profile.c, lasso/saml-2.0/ecp.c,
    lasso/saml-2.0/login.c, lasso/saml-2.0/name_id_management.c,
    lasso/utils.h, lasso/xml/tools.c, lasso/xml/xml.c, swig/Lasso.i:
    Remove use of xmlFreeDoc. Use lasso_release_doc instead.
This commit is contained in:
Benjamin Dauvergne 2008-11-04 01:58:49 +00:00
parent e6b196279f
commit 0d66367f28
23 changed files with 67 additions and 49 deletions

View File

@ -6,6 +6,7 @@
#include "com_entrouvert_lasso_LassoJNI.h"
#include <string.h>
#include "../ghashtable.h"
#include "../../lasso/utils.h"
#define LASSO_ROOT "com/entrouvert/lasso/"
#define check_exception (*env)->ExceptionCheck(env)
@ -337,7 +338,7 @@ jstring_to_xml_node(JNIEnv *env, jstring jstr, xmlNode **xmlnode) {
out:
*xmlnode = node;
if (doc)
xmlFreeDoc(doc);
lasso_release_doc(doc);
if (jstr && local_str)
release_local_string(env, jstr, local_str);
return ret;

View File

@ -6,6 +6,7 @@
#undef PACKAGE_VERSION
#include <lasso/lasso.h>
#include "php_lasso.h"
#include "../../lasso/utils.h"
/* utility functions */
static void free_glist(GList **list, GFunc free_function);
@ -149,7 +150,7 @@ get_xml_node_from_string(char *string)
if (node != NULL) {
node = xmlCopyNode(node, 1);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
return node;
}

View File

@ -7,6 +7,7 @@
#include <lasso/lasso.h>
#include "php_lasso.h"
#include "../ghashtable.h"
#include "../../lasso/utils.h"
/* utility functions */
static void free_glist(GList **list, GFunc free_function);
@ -133,7 +134,7 @@ get_xml_node_from_string(char *string)
if (node != NULL) {
node = xmlCopyNode(node, 1);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
return node;
}

View File

@ -4,6 +4,7 @@
#include <config.h>
#include "../ghashtable.h"
#include "../../lasso/debug.h"
#include "../../lasso/utils.h"
GQuark lasso_wrapper_key;
@ -254,7 +255,7 @@ get_xml_node_from_pystring(PyObject *string) {
if (node != NULL) {
node = xmlCopyNode(node, 1);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
return node;
}

View File

@ -528,12 +528,12 @@ lasso_identity_new_from_dump(const gchar *dump)
rootElement = xmlDocGetRootElement(doc);
if (strcmp((char*)rootElement->name, "Identity") != 0) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
return NULL;
}
identity = lasso_identity_new();
init_from_xml(LASSO_NODE(identity), rootElement);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return identity;
}

View File

@ -33,6 +33,7 @@
#include <lasso/id-ff/lecp.h>
#include <lasso/id-ff/profileprivate.h>
#include "../utils.h"
/*****************************************************************************/
/* public methods */
@ -324,7 +325,7 @@ lasso_lecp_process_authn_request_envelope_msg(LassoLecp *lecp, const char *reque
authn_request = xmlCopyNode(xpathObj->nodesetval->nodeTab[0], 1);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
xmlFreeDoc(doc);
lasso_release_doc(doc);
xpathCtx = NULL;
xpathObj = NULL;
doc = NULL;

View File

@ -173,6 +173,7 @@
#include <lasso/id-ff/loginprivate.h>
#include <lasso/saml-2.0/loginprivate.h>
#include "../utils.h"
static void lasso_login_build_assertion_artifact(LassoLogin *login);
@ -2168,7 +2169,7 @@ lasso_login_new_from_dump(LassoServer *server, const gchar *dump)
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(login), xmlDocGetRootElement(doc));
LASSO_PROFILE(login)->server = g_object_ref(server);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return login;
}

View File

@ -38,6 +38,7 @@
#include <lasso/id-ff/sessionprivate.h>
#include <lasso/saml-2.0/logoutprivate.h>
#include "../utils.h"
static void check_soap_support(gchar *key, LassoProvider *provider, LassoProfile *profile);
@ -1155,7 +1156,7 @@ lasso_logout_new_from_dump(LassoServer *server, const char *dump)
logout = lasso_logout_new(g_object_ref(server));
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(logout), xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
lasso_release_doc(doc);
return logout;
}

View File

@ -31,6 +31,7 @@
#include <lasso/id-ff/name_registration.h>
#include <lasso/id-ff/profileprivate.h>
#include <lasso/id-ff/providerprivate.h>
#include "../utils.h"
/*****************************************************************************/
/* public methods */
@ -759,7 +760,7 @@ lasso_name_registration_new_from_dump(LassoServer *server, const char *dump)
name_registration = lasso_name_registration_new(server);
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(name_registration), xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
lasso_release_doc(doc);
return name_registration;
}

View File

@ -41,6 +41,7 @@
#include <lasso/id-ff/providerprivate.h>
#include <lasso/saml-2.0/profileprivate.h>
#include "../utils.h"
/*****************************************************************************/
/* public functions */
@ -166,7 +167,7 @@ lasso_profile_get_request_type_from_soap_msg(const gchar *soap)
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return type;
}

View File

@ -1057,7 +1057,7 @@ lasso_provider_new_from_dump(const gchar *dump)
provider = g_object_new(LASSO_TYPE_PROVIDER, NULL);
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(provider), xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
lasso_release_doc(doc);
return provider;
}
@ -1120,7 +1120,7 @@ lasso_provider_verify_signature(LassoProvider *provider,
xmlnode = xpathObj->nodesetval->nodeTab[0];
}
if (xmlnode == NULL) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
return LASSO_PROFILE_ERROR_INVALID_MSG;
@ -1153,7 +1153,7 @@ lasso_provider_verify_signature(LassoProvider *provider,
if (sign == NULL) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
return LASSO_DS_ERROR_SIGNATURE_NOT_FOUND;
@ -1173,7 +1173,7 @@ lasso_provider_verify_signature(LassoProvider *provider,
keys_mngr = lasso_load_certs_from_pem_certs_chain_file(
provider->ca_cert_chain);
if (keys_mngr == NULL) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
return LASSO_DS_ERROR_CA_CERT_CHAIN_LOAD_FAILED;
@ -1188,7 +1188,7 @@ lasso_provider_verify_signature(LassoProvider *provider,
xmlSecDSigCtxDestroy(dsigCtx);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return LASSO_DS_ERROR_PUBLIC_KEY_LOAD_FAILED;
}
}
@ -1197,7 +1197,7 @@ lasso_provider_verify_signature(LassoProvider *provider,
xmlSecDSigCtxDestroy(dsigCtx);
if (keys_mngr)
xmlSecKeysMngrDestroy(keys_mngr);
xmlFreeDoc(doc);
lasso_release_doc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
return LASSO_DS_ERROR_SIGNATURE_VERIFICATION_FAILED;
@ -1207,7 +1207,7 @@ lasso_provider_verify_signature(LassoProvider *provider,
if (dsigCtx->status != xmlSecDSigStatusSucceeded) {
xmlSecDSigCtxDestroy(dsigCtx);
xmlFreeDoc(doc);
lasso_release_doc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
return LASSO_DS_ERROR_INVALID_SIGNATURE;
@ -1216,7 +1216,7 @@ lasso_provider_verify_signature(LassoProvider *provider,
xmlSecDSigCtxDestroy(dsigCtx);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return 0;
}

View File

@ -325,7 +325,7 @@ lasso_server_load_affiliation(LassoServer *server, const gchar *filename)
node = xmlDocGetRootElement(doc);
if (node == NULL || node->ns == NULL) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
return LASSO_XML_ERROR_NODE_NOT_FOUND;
}
@ -336,7 +336,7 @@ lasso_server_load_affiliation(LassoServer *server, const gchar *filename)
rc = LASSO_ERROR_UNIMPLEMENTED;
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
return rc;
}

View File

@ -856,13 +856,13 @@ lasso_session_new_from_dump(const gchar *dump)
rootElement = xmlDocGetRootElement(doc);
if (strcmp((char*)rootElement->name, "Session") != 0) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
return NULL;
}
session = lasso_session_new();
init_from_xml(LASSO_NODE(session), rootElement);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return session;
}

View File

@ -39,6 +39,7 @@
#include <lasso/xml/id-wsf-2.0/dstref_modify_response.h>
#include <lasso/xml/soap_fault.h>
#include "../utils.h"
struct _LassoIdWsf2DataServicePrivate
{
@ -284,7 +285,7 @@ lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataService *service)
/* Free XML parsing objects */
xmlUnlinkNode(service->data);
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
lasso_release_doc(doc);
response2 = LASSO_IDWSF2_UTIL_RESPONSE(response);
response2->Status = lasso_idwsf2_util_status_new();
@ -618,7 +619,7 @@ static void set_xml_string(xmlNode **xmlnode, const char* string)
if (node != NULL) {
node = xmlCopyNode(node, 1);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
if (*xmlnode) {
xmlFreeNode(*xmlnode);
@ -811,7 +812,7 @@ lasso_idwsf2_data_service_parse_modify_items(LassoIdWsf2DataService *service)
/* Free XML parsing objects */
xmlXPathFreeContext(cur_xpathCtx);
xmlFreeDoc(cur_doc);
lasso_release_doc(cur_doc);
return res;
}

View File

@ -285,7 +285,7 @@ lasso_data_service_process_query_msg(LassoDataService *service, const char *mess
}
query = LASSO_DST_QUERY(envelope->Body->any->data);
service_type = g_strdup(query->hrefServiceType);
xmlFreeDoc(doc);
lasso_release_doc(doc);
profile = LASSO_WSF_PROFILE(service);
rc = lasso_wsf_profile_process_soap_request_msg(profile, message, service_type,
@ -394,7 +394,7 @@ lasso_data_service_build_response_msg(LassoDataService *service)
xmlUnlinkNode(service->resource_data);
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return lasso_wsf_profile_build_soap_response_msg(profile);
}
@ -793,7 +793,7 @@ lasso_data_service_build_modify_response_msg(LassoDataService *service)
xmlXPathFreeContext(xpathCtx);
g_list_foreach(node_to_free, (GFunc)xmlFreeNode, NULL);
xmlFreeDoc(doc);
lasso_release_doc(doc);
lasso_release_list(node_to_free);
return lasso_wsf_profile_build_soap_response_msg(profile);
@ -824,7 +824,7 @@ lasso_data_service_process_modify_msg(LassoDataService *service,
modify = LASSO_DST_MODIFY(envelope->Body->any->data);
service_type = g_strdup(modify->hrefServiceType);
xmlFreeDoc(doc);
lasso_release_doc(doc);
profile = LASSO_WSF_PROFILE(service);
rc = lasso_wsf_profile_process_soap_request_msg(profile, modify_soap_msg, service_type,

View File

@ -85,6 +85,7 @@
#include <lasso/id-wsf/personal_profile_service.h>
#include <lasso/id-wsf/wsf_profile_private.h>
#include <lasso/id-wsf/utils.h>
#include "../utils.h"
struct _LassoDiscoveryPrivate
{
@ -1179,7 +1180,7 @@ lasso_discovery_build_key_info_node(LassoDiscovery *discovery, const gchar *prov
key_info->KeyValue = key_value;
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return key_info;
}

View File

@ -733,7 +733,7 @@ lasso_wsf_profile_build_soap_response_msg(LassoWsfProfile *profile)
profile->msg_body = g_strdup(
(char*)(buf->conv ? buf->conv->content : buf->buffer->content));
xmlOutputBufferClose(buf);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return 0;
}
@ -798,7 +798,7 @@ exit:
lasso_release_gobject(envelope);
}
if (doc) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
}
return rc;
@ -871,7 +871,7 @@ exit:
lasso_release_gobject(envelope);
}
if (doc) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
}
return rc;
}

View File

@ -40,6 +40,7 @@
#include <lasso/saml-2.0/ecpprivate.h>
#include <lasso/saml-2.0/ecp.h>
#include "../utils.h"
/*****************************************************************************/
/* public methods */
@ -174,7 +175,7 @@ lasso_ecp_process_authn_request_msg(LassoEcp *ecp, const char *authn_request_msg
LASSO_PROFILE(ecp)->msg_body = g_strdup(
(char*)(buf->conv ? buf->conv->content : buf->buffer->content));
xmlOutputBufferClose(buf);
xmlFreeDoc(doc);
lasso_release_doc(doc);
profile->remote_providerID = lasso_server_get_first_providerID(profile->server);
if (profile->remote_providerID == NULL) {
@ -277,7 +278,7 @@ lasso_ecp_process_response_msg(LassoEcp *ecp, const char *response_msg)
(char*)(buf->conv ? buf->conv->content : buf->buffer->content));
xmlOutputBufferClose(buf);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return 0;
}

View File

@ -63,6 +63,8 @@
#include <lasso/xml/id-wsf-2.0/sec_token.h>
#endif
#include "../utils.h"
static int lasso_saml20_login_process_federation(LassoLogin *login, gboolean is_consent_obtained);
static gboolean lasso_saml20_login_must_ask_for_consent_private(LassoLogin *login);
static gint lasso_saml20_login_process_response_status_and_assertion(LassoLogin *login);
@ -1087,7 +1089,7 @@ lasso_saml20_login_process_paos_response_msg(LassoLogin *login, gchar *msg)
xmlnode = xpathObj->nodesetval->nodeTab[0];
}
if (xmlnode == NULL) {
xmlFreeDoc(doc);
lasso_release_doc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
return LASSO_PROFILE_ERROR_INVALID_MSG;
@ -1101,7 +1103,7 @@ lasso_saml20_login_process_paos_response_msg(LassoLogin *login, gchar *msg)
}
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
xmlFreeDoc(doc);
lasso_release_doc(doc);
profile->response = response;
profile->remote_providerID = g_strdup(

View File

@ -30,6 +30,7 @@
#include <lasso/id-ff/identityprivate.h>
#include <lasso/id-ff/serverprivate.h>
#include <lasso/xml/xml_enc.h>
#include "../utils.h"
/**
* SECTION:name_id_management
@ -796,7 +797,7 @@ lasso_name_id_management_new_from_dump(LassoServer *server, const char *dump)
name_id_management = lasso_name_id_management_new(g_object_ref(server));
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(name_id_management), xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
lasso_release_doc(doc);
return name_id_management;
}

View File

@ -47,6 +47,7 @@
#include <lasso/xml/saml-2.0/saml2_assertion.h>
#include <unistd.h>
#include "../debug.h"
#include "../utils.h"
LassoNode* lasso_assertion_encrypt(LassoSaml2Assertion *assertion);
static xmlSecKeyPtr lasso_get_public_key_from_private_key_file(const char *private_key_file);
@ -787,7 +788,7 @@ lasso_sign_node(xmlNode *xmlnode, const char *id_attr_name, const char *id_value
/* memory leak since we don't free doc but it causes some little memory
* corruption; probably caused by the direct manipulation of xmlnode
* parent attribute. */
xmlFreeDoc(doc);
lasso_release_doc(doc);
#endif
return 0;
@ -917,7 +918,7 @@ lasso_node_init_from_deflated_query_part(LassoNode *node, char *deflate_string)
xmlFree(re);
root = xmlDocGetRootElement(doc);
lasso_node_init_from_xml(node, root);
xmlFreeDoc(doc);
lasso_release_doc(doc);
return TRUE;
}

View File

@ -205,7 +205,7 @@ lasso_xml_parse_memory(const char *buffer, int size)
ret = ctxt->myDoc;
} else {
ret = NULL;
xmlFreeDoc(ctxt->myDoc);
lasso_release_doc(ctxt->myDoc);
ctxt->myDoc = NULL;
}
xmlFreeParserCtxt(ctxt);
@ -864,7 +864,7 @@ cleanup:
if (encCtx) {
xmlSecEncCtxDestroy(encCtx);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
return decrypted_node;
}
@ -1562,7 +1562,7 @@ lasso_node_new_from_dump(const char *dump)
node = lasso_node_new_from_xmlNode(xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
lasso_release_doc(doc);
return node;
}
@ -1594,7 +1594,7 @@ lasso_node_new_from_soap(const char *soap)
node = lasso_node_new_from_xmlNode(xmlnode);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
@ -1842,7 +1842,7 @@ lasso_node_init_from_message(LassoNode *node, const char *message)
lasso_node_init_from_xml(node, root);
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
lasso_release_doc(doc);
if (xpathCtx) {
/* this tests a pointer which has been freed, it works
* but is not really elegant */

View File

@ -71,6 +71,8 @@
#include <lasso/xml/disco_encrypted_resource_id.h>
#endif
#include "../lasso/utils.h"
%}
/* GLib types */
@ -1488,7 +1490,7 @@ static xmlNode *get_string_xml(const char *string) {
if (node != NULL) {
node = xmlCopyNode(node, 1);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
return node;
}
@ -1588,7 +1590,7 @@ static void set_xml_list(GList **xmlListPointer, GPtrArray *xmlArray) {
if (node != NULL) {
node = xmlCopyNode(node, 1);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
}
*xmlListPointer = g_list_append(*xmlListPointer, node);
}
@ -1605,7 +1607,7 @@ static void set_xml_string(xmlNode **xmlnode, const char* string)
if (node != NULL) {
node = xmlCopyNode(node, 1);
}
xmlFreeDoc(doc);
lasso_release_doc(doc);
if (*xmlnode) {
xmlFreeNode(*xmlnode);