diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-06-02 17:09:17 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-06-02 17:09:17 +0000 |
commit | 7e5b06813d2cf4d314d577d9b11f2cac13835faa (patch) | |
tree | 35e12230b047125adf45685c2ec064a2df017ab4 /crypto/engine/tb_pkmeth.c | |
parent | 1892c8bf979ebb759ca8c1f3e454cb659eb75ae5 (diff) |
Automatically free up dynamically allocated public key methods when
and ENGINE is destroyed.
Diffstat (limited to 'crypto/engine/tb_pkmeth.c')
-rw-r--r-- | crypto/engine/tb_pkmeth.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/crypto/engine/tb_pkmeth.c b/crypto/engine/tb_pkmeth.c index b99dea2190..999fc0ac41 100644 --- a/crypto/engine/tb_pkmeth.c +++ b/crypto/engine/tb_pkmeth.c @@ -118,7 +118,7 @@ ENGINE *ENGINE_get_pkey_meth_engine(int nid) /* Obtains a pkey_meth implementation from an ENGINE functional reference */ const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid) { - const EVP_PKEY_METHOD *ret; + EVP_PKEY_METHOD *ret; ENGINE_PKEY_METHS_PTR fn = ENGINE_get_pkey_meths(e); if(!fn || !fn(e, &ret, NULL, nid)) { @@ -141,3 +141,26 @@ int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f) e->pkey_meths = f; return 1; } + +/* Internal function to free up EVP_PKEY_METHOD structures before an + * ENGINE is destroyed + */ + +void engine_pkey_meths_free(ENGINE *e) + { + int i; + EVP_PKEY_METHOD *pkm; + if (e->pkey_meths) + { + const int *pknids; + int npknids; + npknids = e->pkey_meths(e, NULL, &pknids, 0); + for (i = 0; i < npknids; i++) + { + if (e->pkey_meths(e, &pkm, NULL, pknids[i])) + { + EVP_PKEY_meth_free(pkm); + } + } + } + } |