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

Commit

Permalink
src: fix potential memory leak on early return
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex authored and indutny committed Apr 21, 2013
1 parent 2322580 commit c4379a5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3009,16 +3009,16 @@ class Sign : public ObjectWrap {
unsigned int md_len;
Local<Value> outString;

md_len = 8192; // Maximum key size is 8192 bits
md_value = new unsigned char[md_len];

ASSERT_IS_BUFFER(args[0]);
ssize_t len = Buffer::Length(args[0]);

char* buf = new char[len];
ssize_t written = DecodeWrite(buf, len, args[0], BUFFER);
assert(written == len);

md_len = 8192; // Maximum key size is 8192 bits
md_value = new unsigned char[md_len];

int r = sign->SignFinal(&md_value, &md_len, buf, len);
if (r == 0) {
md_value = NULL;
Expand Down

0 comments on commit c4379a5

Please sign in to comment.