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

Commit

Permalink
Fix memory leak in node_crypto.cc.
Browse files Browse the repository at this point in the history
Both HexDecode and unbase64 allocate buffers, which weren't being freed.
  • Loading branch information
thughes authored and ry committed Dec 22, 2010
1 parent 4b55509 commit b38f471
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1719,19 +1719,19 @@ class Decipher : public ObjectWrap {

if (alloc_buf) {
delete [] buf;
alloc_buf = false;
}
buf = ciphertext;
len = ciphertext_len;
alloc_buf = true;

} else if (strcasecmp(*encoding, "base64") == 0) {
unbase64((unsigned char*)buf, len, (char **)&ciphertext, &ciphertext_len);
if (alloc_buf) {
delete [] buf;
alloc_buf = false;
}
buf = ciphertext;
len = ciphertext_len;
alloc_buf = true;

} else if (strcasecmp(*encoding, "binary") == 0) {
// Binary - do nothing
Expand Down

0 comments on commit b38f471

Please sign in to comment.