Fix leak of mapping registry
* lasso/lasso.c: * lasso/registry-private.h: * lasso/registry.c: make the registry be freed in lasso_shutdown.
This commit is contained in:
parent
e3bdadf8f7
commit
1b0d28b102
|
@ -38,6 +38,7 @@
|
|||
#include "lasso.h"
|
||||
#include "debug.h"
|
||||
#include "./backward_comp.h"
|
||||
#include "./registry-private.h"
|
||||
|
||||
/* Set to true, it forces lasso_provider_verify_signature and lasso_query_verify_signature to always
|
||||
* return TRUE. */
|
||||
|
@ -166,6 +167,10 @@ int lasso_shutdown()
|
|||
#endif /* XMLSEC_NO_XSLT */
|
||||
/* Cleanup function for the XML library */
|
||||
xmlCleanupParser();
|
||||
|
||||
/* Disallocate default registry */
|
||||
lasso_registry_default_shutdown();
|
||||
|
||||
if (lasso_flag_memory_debug == TRUE) {
|
||||
/* this is to debug memory for regression tests */
|
||||
xmlMemoryDump();
|
||||
|
|
|
@ -40,6 +40,8 @@ struct _LassoRegistry {
|
|||
};
|
||||
|
||||
LassoRegistry *lasso_registry_new();
|
||||
void lasso_registry_destroy();
|
||||
void lasso_registry_default_shutdown();
|
||||
gint lasso_registry_add_direct_mapping(LassoRegistry *registry, const char *from_namespace,
|
||||
const char *from_name, const char *to_namespace, const char *to_name);
|
||||
gint lasso_registry_add_functional_mapping(LassoRegistry *registry, const char *from_namespace,
|
||||
|
|
|
@ -64,14 +64,21 @@ struct _LassoRegistryFunctionalMappingRecord {
|
|||
LassoRegistryTranslationFunction translation_function;
|
||||
};
|
||||
|
||||
static LassoRegistry *default_registry = NULL;
|
||||
|
||||
static LassoRegistry *lasso_registry_get_default() {
|
||||
static LassoRegistry *default_registry = NULL;
|
||||
if (default_registry == NULL) {
|
||||
default_registry = lasso_registry_new();
|
||||
}
|
||||
return default_registry;
|
||||
}
|
||||
|
||||
void lasso_registry_default_shutdown()
|
||||
{
|
||||
lasso_registry_destroy(default_registry);
|
||||
default_registry = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* lasso_registry_direct_mapping_equal:
|
||||
* @record1: left record
|
||||
|
@ -143,17 +150,36 @@ LassoRegistry *lasso_registry_new()
|
|||
{
|
||||
LassoRegistry *ret = g_new0(LassoRegistry, 1);
|
||||
|
||||
ret->direct_mapping = g_hash_table_new(
|
||||
ret->direct_mapping = g_hash_table_new_full(
|
||||
(GHashFunc) lasso_registry_direct_mapping_hash,
|
||||
(GEqualFunc) lasso_registry_direct_mapping_equal);
|
||||
(GEqualFunc) lasso_registry_direct_mapping_equal,
|
||||
NULL,
|
||||
g_free);
|
||||
|
||||
ret->functional_mapping = g_hash_table_new(
|
||||
ret->functional_mapping = g_hash_table_new_full(
|
||||
(GHashFunc) lasso_registry_functional_mapping_hash,
|
||||
(GEqualFunc) lasso_registry_functional_mapping_equal);
|
||||
(GEqualFunc) lasso_registry_functional_mapping_equal,
|
||||
NULL,
|
||||
g_free);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* lasso_registry_destroy:
|
||||
* @registry: the #LassoRegistry object
|
||||
*
|
||||
* Destroy a #LassoRegistry.
|
||||
*/
|
||||
void lasso_registry_destroy(LassoRegistry *registry)
|
||||
{
|
||||
g_hash_table_destroy(registry->direct_mapping);
|
||||
registry->direct_mapping = NULL;
|
||||
g_hash_table_destroy(registry->functional_mapping);
|
||||
registry->functional_mapping = NULL;
|
||||
g_free(registry);
|
||||
}
|
||||
|
||||
static LassoRegistryTranslationFunction lasso_registry_get_translation_function(GHashTable *functional_mappings, GQuark from_ns_quark, GQuark to_ns_quark)
|
||||
{
|
||||
LassoRegistryFunctionalMappingRecord functional_mapping, *functional_mapping_found;
|
||||
|
|
Loading…
Reference in New Issue