summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2011-09-07 17:29:34 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2011-09-07 20:02:14 +0200
commit638773628cf8568025d51fd9582ed11a5866be28 (patch)
tree1f27aab37018edb9185a9f8655fbb45c656b1f16 /src
parenteb99083d0bbca437e62d0959ca8dd0cb73bb04fa (diff)
downloadnodejs-638773628cf8568025d51fd9582ed11a5866be28.tar.gz
nodejs-638773628cf8568025d51fd9582ed11a5866be28.tar.bz2
nodejs-638773628cf8568025d51fd9582ed11a5866be28.zip
tls: new[] instead of malloc() in Connection::GetSession()
Diffstat (limited to 'src')
-rw-r--r--src/node_crypto.cc22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 04ebbc6c9..36417040b 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -1191,24 +1191,16 @@ Handle<Value> Connection::GetSession(const Arguments& args) {
int slen = i2d_SSL_SESSION(sess, NULL);
assert(slen > 0);
- Local<Value> s;
-
if (slen > 0) {
- void* pp = malloc(slen);
- if (pp)
- {
- unsigned char* p = (unsigned char*)pp;
- i2d_SSL_SESSION(sess, &p);
- s = Encode(pp, slen, BINARY);
- free(pp);
- }
- else
- return False();
+ unsigned char* sbuf = new unsigned char[slen];
+ unsigned char* p = sbuf;
+ i2d_SSL_SESSION(sess, &p);
+ Local<Value> s = Encode(sbuf, slen, BINARY);
+ delete[] sbuf;
+ return scope.Close(s);
}
- else
- return False();
- return scope.Close(s);
+ return Null();
}
Handle<Value> Connection::SetSession(const Arguments& args) {