Browse Source

crypto: fix DecipherUpdate() memory leak

Fix a memory leak in the the code path that deals with partial hex strings.
v0.8.7-release
Ben Noordhuis 13 years ago
parent
commit
26f1bc8e8c
  1. 6
      src/node_crypto.cc

6
src/node_crypto.cc

@ -2641,10 +2641,8 @@ class Decipher : public ObjectWrap {
char* complete_hex = new char[len+2]; char* complete_hex = new char[len+2];
memcpy(complete_hex, &cipher->incomplete_hex, 1); memcpy(complete_hex, &cipher->incomplete_hex, 1);
memcpy(complete_hex+1, buf, len); memcpy(complete_hex+1, buf, len);
if (alloc_buf) { if (alloc_buf) delete [] buf;
delete [] buf; alloc_buf = true;
alloc_buf = false;
}
buf = complete_hex; buf = complete_hex;
len += 1; len += 1;
} }

Loading…
Cancel
Save