diff options
author | Richard Levitte <levitte@openssl.org> | 2019-08-21 09:58:10 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-08-22 01:50:30 +0200 |
commit | b1d40ddfe23fd9551b89cdcfa52d1c23fc667f8a (patch) | |
tree | 1eb6cc4b725753f4f20a5e2ded72fcd1a919a114 /crypto/property | |
parent | Fix ossl_param_bld_push_{utf8,octet}_string() / param_bld_convert() (diff) | |
download | openssl-b1d40ddfe23fd9551b89cdcfa52d1c23fc667f8a.tar.xz openssl-b1d40ddfe23fd9551b89cdcfa52d1c23fc667f8a.zip |
Modify ossl_method_store_add() to handle reference counting
Because this function affects the reference count on failure (the call
to impl_free() does this), it may as well handle incrementing it as
well to indicate the extra reference in the method store.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9650)
Diffstat (limited to 'crypto/property')
-rw-r--r-- | crypto/property/property.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/property/property.c b/crypto/property/property.c index c3fa8df9c6..6576ba0fd2 100644 --- a/crypto/property/property.c +++ b/crypto/property/property.c @@ -174,8 +174,9 @@ static int ossl_method_store_insert(OSSL_METHOD_STORE *store, ALGORITHM *alg) } int ossl_method_store_add(OSSL_METHOD_STORE *store, - int nid, const char *properties, - void *method, void (*method_destruct)(void *)) + int nid, const char *properties, void *method, + int (*method_up_ref)(void *), + void (*method_destruct)(void *)) { ALGORITHM *alg = NULL; IMPLEMENTATION *impl; @@ -190,6 +191,8 @@ int ossl_method_store_add(OSSL_METHOD_STORE *store, impl = OPENSSL_malloc(sizeof(*impl)); if (impl == NULL) return 0; + if (method_up_ref != NULL && !method_up_ref(method)) + return 0; impl->method = method; impl->method_destruct = method_destruct; |