summaryrefslogtreecommitdiff
path: root/p11-kit
diff options
context:
space:
mode:
Diffstat (limited to 'p11-kit')
-rw-r--r--p11-kit/hashmap.c7
-rw-r--r--p11-kit/modules.c6
2 files changed, 11 insertions, 2 deletions
diff --git a/p11-kit/hashmap.c b/p11-kit/hashmap.c
index 1c4aff1..d420221 100644
--- a/p11-kit/hashmap.c
+++ b/p11-kit/hashmap.c
@@ -157,11 +157,16 @@ _p11_hash_set (hashmap *map,
bucketp = lookup_or_create_bucket (map, key, 1);
if(bucketp && *bucketp) {
+ /* Destroy the previous key */
+ if ((*bucketp)->key && (*bucketp)->key != key && map->key_destroy_func)
+ map->key_destroy_func ((*bucketp)->key);
+
/* Destroy the previous value */
- if ((*bucketp)->value && map->value_destroy_func)
+ if ((*bucketp)->value && (*bucketp)->value != val && map->value_destroy_func)
map->value_destroy_func ((*bucketp)->value);
/* replace entry */
+ (*bucketp)->key = key;
(*bucketp)->value = val;
/* check that the collision rate isn't too high */
diff --git a/p11-kit/modules.c b/p11-kit/modules.c
index a4ffc43..c097c4b 100644
--- a/p11-kit/modules.c
+++ b/p11-kit/modules.c
@@ -390,6 +390,7 @@ take_config_and_load_module_unlocked (char **name, hashmap **config)
Module *mod, *prev;
const char *module_filename;
char *path;
+ char *key;
CK_RV rv;
assert (name);
@@ -409,8 +410,11 @@ take_config_and_load_module_unlocked (char **name, hashmap **config)
path = expand_module_path (module_filename);
return_val_if_fail (path != NULL, CKR_HOST_MEMORY);
+ key = strdup ("module");
+ return_val_if_fail (key != NULL, CKR_HOST_MEMORY);
+
/* The hash map will take ownership of the variable */
- if (!_p11_hash_set (*config, "module", path))
+ if (!_p11_hash_set (*config, key, path))
return_val_if_reached (CKR_HOST_MEMORY);
mod = alloc_module_unlocked ();