server: Fix several memory leak while running valgrind on freerdp-shadow

This commit is contained in:
zihao.jiang 2015-09-15 23:17:22 +08:00
parent 02c86dece4
commit f21749ac07
4 changed files with 37 additions and 35 deletions

View File

@ -782,6 +782,8 @@ void rdpsnd_server_context_free(RdpsndServerContext* context)
free(context->client_formats);
free(context->priv);
free(context);
}

View File

@ -983,7 +983,6 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPS
goto error_receiveData;
}
channel->queue = MessageQueue_New(NULL);
channel->queue = MessageQueue_New(NULL);
if (!channel->queue)
goto error_queue;

View File

@ -710,7 +710,14 @@ rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, BYTE* imageData, int imageS
void rdtk_font_free(rdtkFont* font)
{
free(font);
if (font)
{
free(font->family);
free(font->style);
winpr_image_free(font->image, TRUE);
free(font->glyphs);
free(font);
}
}
int rdtk_font_engine_init(rdtkEngine* engine)

View File

@ -625,6 +625,7 @@ int shadow_server_init(rdpShadowServer* server)
if (status >= 0)
return status;
shadow_subsystem_free(server->subsystem);
fail_subsystem_new:
freerdp_listener_free(server->listener);
server->listener = NULL;
@ -651,34 +652,34 @@ fail_client_array:
int shadow_server_uninit(rdpShadowServer* server)
{
if (!server)
return -1;
shadow_server_stop(server);
if (server->listener)
{
freerdp_listener_free(server->listener);
server->listener = NULL;
}
if (server->CertificateFile)
{
free(server->CertificateFile);
server->CertificateFile = NULL;
}
if (server->PrivateKeyFile)
{
free(server->PrivateKeyFile);
server->PrivateKeyFile = NULL;
}
if (server->ipcSocket)
{
free(server->ipcSocket);
server->ipcSocket = NULL;
}
shadow_subsystem_uninit(server->subsystem);
shadow_subsystem_free(server->subsystem);
freerdp_listener_free(server->listener);
server->listener = NULL;
free(server->CertificateFile);
server->CertificateFile = NULL;
free(server->PrivateKeyFile);
server->PrivateKeyFile = NULL;
free(server->ConfigPath);
server->ConfigPath = NULL;
DeleteCriticalSection(&(server->lock));
CloseHandle(server->StopEvent);
server->StopEvent = NULL;
ArrayList_Free(server->clients);
server->clients = NULL;
return 1;
}
@ -705,15 +706,8 @@ void shadow_server_free(rdpShadowServer* server)
if (!server)
return;
DeleteCriticalSection(&(server->lock));
if (server->clients)
{
ArrayList_Free(server->clients);
server->clients = NULL;
}
shadow_subsystem_free(server->subsystem);
free(server->ipcSocket);
server->ipcSocket = NULL;
free(server);
}