Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrement ref counter only once on key object free #528

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/p11_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ void pkcs11_object_free(PKCS11_OBJECT_private *obj)
if(!obj)
return;

if (pkcs11_atomic_add(&obj->refcnt, -1, &obj->lock) != 0)
return;
if (obj->evp_key) {
/* When the EVP object is reference count goes to zero,
* it will call this function again. */
Expand All @@ -195,6 +193,10 @@ void pkcs11_object_free(PKCS11_OBJECT_private *obj)
EVP_PKEY_free(pkey);
return;
}

if (pkcs11_atomic_add(&obj->refcnt, -1, &obj->lock) != 0)
return;

pkcs11_slot_unref(obj->slot);
X509_free(obj->x509);
OPENSSL_free(obj->label);
Expand Down
Loading