diff options
author | David Benjamin <davidben@chromium.org> | 2014-08-06 05:46:37 +0400 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-08-07 04:03:56 +0400 |
commit | e6e15fc3a19ac6e4317d7245df24313c261fc2bb (patch) | |
tree | be8cbfd4a795836e3a519fac7f2ed3a181d55733 /crypto/x509 | |
parent | bf681a40d6142edfa44a27dc0d6e07e0c37865a4 (diff) |
Use EVP_PKEY_dup instead of manually incrementing the refcount.
Reference counting should be internal to the type, otherwise callers need to
know which lock to use.
Change-Id: If4d805876a321ef6dece115c805e605584ff311e
Reviewed-on: https://boringssl-review.googlesource.com/1414
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/x_pubkey.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index d1b21465..04275f76 100644 --- a/crypto/x509/x_pubkey.c +++ b/crypto/x509/x_pubkey.c @@ -133,8 +133,7 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) if (key->pkey != NULL) { - CRYPTO_add(&key->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); - return key->pkey; + return EVP_PKEY_dup(key->pkey); } if (key->public_key == NULL) goto error; @@ -178,9 +177,8 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) key->pkey = ret; CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY); } - CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY); - return ret; + return EVP_PKEY_dup(ret); error: if (ret != NULL) |