]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
A deinit function implies GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE. Based on patch by...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 4 Jul 2012 15:49:51 +0000 (17:49 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 4 Jul 2012 15:49:51 +0000 (17:49 +0200)
lib/gnutls_privkey.c

index e87f1ab69fdfba10e1a5f75b1405581c9c346e01..de8061f5ab9eef03c1e152cad22c46eedcf235c5 100644 (file)
@@ -435,7 +435,8 @@ int ret;
  *
  * This function will associate the given callbacks with the
  * #gnutls_privkey_t structure. At least one of the two callbacks
- * must be non-null.
+ * must be non-null. If a deinitialization function is provided
+ * then flags is assumed to contain %GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE.
  *
  * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
  *   negative error value.
@@ -471,6 +472,10 @@ int ret;
   pkey->pk_algorithm = pk;
   pkey->flags = flags;
 
+  /* Ensure gnutls_privkey_deinit() calls the deinit_func */
+  if (deinit_func)
+    pkey->flags |= GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE;
+
   return 0;
 }