From b2d24a4dd24afb3a89d94bbb1a680ab1e1a06601 Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Mon, 14 Mar 2016 15:27:15 +0100 Subject: [PATCH] freerdp: Fix possible crash when setting error info in server-mode --- libfreerdp/core/freerdp.c | 6 +++++- libfreerdp/core/rdp.c | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 0f45f1284..d2d4f0c69 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -627,7 +627,11 @@ UINT32 freerdp_error_info(freerdp* instance) return instance->context->rdp->errorInfo; } -void freerdp_set_error_info(rdpRdp* rdp, UINT32 error) { +void freerdp_set_error_info(rdpRdp* rdp, UINT32 error) +{ + if (!rdp) + return; + rdp_set_error_info(rdp, error); } diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index b433566f7..8f3289038 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -248,15 +248,19 @@ BOOL rdp_set_error_info(rdpRdp* rdp, UINT32 errorInfo) if (rdp->errorInfo != ERRINFO_SUCCESS) { - ErrorInfoEventArgs e; - rdpContext* context = rdp->instance->context; - - rdp->context->LastError = MAKE_FREERDP_ERROR(ERRINFO, errorInfo); + rdpContext* context = rdp->context; rdp_print_errinfo(rdp->errorInfo); - - EventArgsInit(&e, "freerdp"); - e.code = rdp->errorInfo; - PubSub_OnErrorInfo(context->pubSub, context, &e); + if (context) + { + context->LastError = MAKE_FREERDP_ERROR(ERRINFO, errorInfo); + if (context->pubSub) + { + ErrorInfoEventArgs e; + EventArgsInit(&e, "freerdp"); + e.code = rdp->errorInfo; + PubSub_OnErrorInfo(context->pubSub, context, &e); + } + } } else {