Copy the name of pkcs11_library_t objects
authorTobias Brunner <tobias@strongswan.org>
Mon, 8 Oct 2012 09:15:35 +0000 (11:15 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 18 Oct 2012 12:42:09 +0000 (14:42 +0200)
Strings returned by settings_t.create_section_enumerator will be freed
when the config is reloaded.

src/libstrongswan/plugins/pkcs11/pkcs11_library.c
src/libstrongswan/plugins/pkcs11/pkcs11_library.h

index 97c3d2f..0d89a97 100644 (file)
@@ -895,6 +895,7 @@ METHOD(pkcs11_library_t, destroy, void,
 {
        this->public.f->C_Finalize(NULL);
        dlclose(this->handle);
+       free(this->name);
        free(this);
 }
 
@@ -1077,7 +1078,7 @@ pkcs11_library_t *pkcs11_library_create(char *name, char *file, bool os_locking)
                        .get_ck_attribute = _get_ck_attribute,
                        .destroy = _destroy,
                },
-               .name = name,
+               .name = strdup(name),
                .handle = dlopen(file, RTLD_LAZY),
        );
 
index e76e65e..50ed036 100644 (file)
@@ -161,7 +161,7 @@ void pkcs11_library_trim(char *str, int len);
 /**
  * Create a pkcs11_library instance.
  *
- * @param name         an arbitrary name, for debugging
+ * @param name         an arbitrary name (for debugging), cloned
  * @param file         pkcs11 library file to dlopen()
  * @param os_lock      enforce OS Locking for this library
  * @return                     library abstraction