Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix resource leaks in node_crypto.cc
Browse files Browse the repository at this point in the history
Fixes #1097.
  • Loading branch information
bnoordhuis authored and ry committed May 25, 2011
1 parent 9b34726 commit eb4c9ed
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions src/node_crypto.cc
Expand Up @@ -1677,8 +1677,10 @@ class Cipher : public ObjectWrap {
initialised_ = false;
}

~Cipher ()
{
~Cipher () {
if (initialised_) {
EVP_CIPHER_CTX_cleanup(&ctx);
}
}

private:
Expand Down Expand Up @@ -2126,7 +2128,11 @@ class Decipher : public ObjectWrap {
initialised_ = false;
}

~Decipher () { }
~Decipher () {
if (initialised_) {
EVP_CIPHER_CTX_cleanup(&ctx);
}
}

private:

Expand Down Expand Up @@ -2316,7 +2322,11 @@ class Hmac : public ObjectWrap {
initialised_ = false;
}

~Hmac () { }
~Hmac () {
if (initialised_) {
HMAC_CTX_cleanup(&ctx);
}
}

private:

Expand Down Expand Up @@ -2472,7 +2482,11 @@ class Hash : public ObjectWrap {
initialised_ = false;
}

~Hash () { }
~Hash () {
if (initialised_) {
EVP_MD_CTX_cleanup(&mdctx);
}
}

private:

Expand Down Expand Up @@ -2677,7 +2691,11 @@ class Sign : public ObjectWrap {
initialised_ = false;
}

~Sign () { }
~Sign () {
if (initialised_) {
EVP_MD_CTX_cleanup(&mdctx);
}
}

private:

Expand Down Expand Up @@ -2893,7 +2911,11 @@ class Verify : public ObjectWrap {
initialised_ = false;
}

~Verify () { }
~Verify () {
if (initialised_) {
EVP_MD_CTX_cleanup(&mdctx);
}
}

private:

Expand Down

0 comments on commit eb4c9ed

Please sign in to comment.