src: fix potential memory leak on early return

pull/5010/head
mscdex 2013-04-20 23:21:13 -04:00 committed by Fedor Indutny
parent 2322580dfb
commit c4379a5554
1 changed files with 3 additions and 3 deletions

View File

@ -3009,9 +3009,6 @@ 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]);
@ -3019,6 +3016,9 @@ class Sign : public ObjectWrap {
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;