Skip to content

Commit

Permalink
setting pointers to NULL after freeing memory to avoid crashes.
Browse files Browse the repository at this point in the history
gitignore: only top-level "external" folder is ignored.
  • Loading branch information
Benoît LeBlanc committed Oct 22, 2013
1 parent 3951a6e commit 5bfca61
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DartConfiguration.tcl
CMakeCPackOptions.cmake
_CPack_Packages
LICENSE.txt
external/*
/external/*
!external/README

*.a.objlist.cmake
Expand Down
11 changes: 7 additions & 4 deletions client/common/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
void freerdp_client_context_free(rdpContext* context)
{
freerdp* instance = context->instance;

freerdp_context_free(instance);
free(instance->pClientEntryPoints);
freerdp_free(instance);
if (instance)
{
freerdp_context_free(instance);
free(instance->pClientEntryPoints);
freerdp_free(instance);
context->instance = NULL;
}
}

int freerdp_client_start(rdpContext* context)
Expand Down
11 changes: 11 additions & 0 deletions libfreerdp/crypto/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,21 +798,32 @@ void tls_free(rdpTls* tls)
if (tls != NULL)
{
if (tls->ssl)
{
SSL_free(tls->ssl);
tls->ssl = NULL;
}

if (tls->ctx)
{
SSL_CTX_free(tls->ctx);
tls->ctx = NULL;
}

if (tls->PublicKey)
{
free(tls->PublicKey);
tls->PublicKey = NULL;
}

if (tls->Bindings)
{
free(tls->Bindings->Bindings);
free(tls->Bindings);
tls->Bindings = NULL;
}

certificate_store_free(tls->certificate_store);
tls->certificate_store = NULL;

free(tls);
}
Expand Down

0 comments on commit 5bfca61

Please sign in to comment.