tls: new[] instead of malloc() in Connection::GetSession()

v0.7.4-release
Ben Noordhuis 2011-09-07 17:29:34 +02:00
parent eb99083d0b
commit 638773628c
1 changed files with 7 additions and 15 deletions

View File

@ -1191,24 +1191,16 @@ Handle<Value> Connection::GetSession(const Arguments& args) {
int slen = i2d_SSL_SESSION(sess, NULL); int slen = i2d_SSL_SESSION(sess, NULL);
assert(slen > 0); assert(slen > 0);
Local<Value> s;
if (slen > 0) { if (slen > 0) {
void* pp = malloc(slen); unsigned char* sbuf = new unsigned char[slen];
if (pp) unsigned char* p = sbuf;
{ i2d_SSL_SESSION(sess, &p);
unsigned char* p = (unsigned char*)pp; Local<Value> s = Encode(sbuf, slen, BINARY);
i2d_SSL_SESSION(sess, &p); delete[] sbuf;
s = Encode(pp, slen, BINARY); return scope.Close(s);
free(pp);
}
else
return False();
} }
else
return False();
return scope.Close(s); return Null();
} }
Handle<Value> Connection::SetSession(const Arguments& args) { Handle<Value> Connection::SetSession(const Arguments& args) {