#6488 Fixed a memory leak in the TLS socket code
This commit is contained in:
parent
9bccfb89cc
commit
a56abf68dd
|
@ -199,6 +199,7 @@ SecureSocket::doWrite()
|
||||||
{
|
{
|
||||||
static bool s_retry = false;
|
static bool s_retry = false;
|
||||||
static int s_retrySize = 0;
|
static int s_retrySize = 0;
|
||||||
|
static int s_staticBufferSize = 0;
|
||||||
static void* s_staticBuffer = NULL;
|
static void* s_staticBuffer = NULL;
|
||||||
|
|
||||||
// write data
|
// write data
|
||||||
|
@ -211,8 +212,13 @@ SecureSocket::doWrite()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bufferSize = m_outputBuffer.getSize();
|
bufferSize = m_outputBuffer.getSize();
|
||||||
s_staticBuffer = malloc(bufferSize);
|
if (bufferSize != 0) {
|
||||||
memcpy(s_staticBuffer, m_outputBuffer.peek(bufferSize), bufferSize);
|
if (bufferSize > s_staticBufferSize) {
|
||||||
|
s_staticBuffer = realloc(s_staticBuffer, bufferSize);
|
||||||
|
s_staticBufferSize = bufferSize;
|
||||||
|
}
|
||||||
|
memcpy(s_staticBuffer, m_outputBuffer.peek(bufferSize), bufferSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufferSize == 0) {
|
if (bufferSize == 0) {
|
||||||
|
@ -224,8 +230,6 @@ SecureSocket::doWrite()
|
||||||
if (status > 0) {
|
if (status > 0) {
|
||||||
s_retry = false;
|
s_retry = false;
|
||||||
bufferSize = 0;
|
bufferSize = 0;
|
||||||
free(s_staticBuffer);
|
|
||||||
s_staticBuffer = NULL;
|
|
||||||
}
|
}
|
||||||
else if (status < 0) {
|
else if (status < 0) {
|
||||||
return kBreak;
|
return kBreak;
|
||||||
|
|
Loading…
Reference in New Issue