freerdp: Fix possible crash when setting error info in server-mode

This commit is contained in:
Martin Fleisz 2016-03-14 15:27:15 +01:00
parent 05bcec47b8
commit b2d24a4dd2
2 changed files with 17 additions and 9 deletions

View File

@ -627,7 +627,11 @@ UINT32 freerdp_error_info(freerdp* instance)
return instance->context->rdp->errorInfo; 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); rdp_set_error_info(rdp, error);
} }

View File

@ -248,15 +248,19 @@ BOOL rdp_set_error_info(rdpRdp* rdp, UINT32 errorInfo)
if (rdp->errorInfo != ERRINFO_SUCCESS) if (rdp->errorInfo != ERRINFO_SUCCESS)
{ {
ErrorInfoEventArgs e; rdpContext* context = rdp->context;
rdpContext* context = rdp->instance->context;
rdp->context->LastError = MAKE_FREERDP_ERROR(ERRINFO, errorInfo);
rdp_print_errinfo(rdp->errorInfo); rdp_print_errinfo(rdp->errorInfo);
if (context)
EventArgsInit(&e, "freerdp"); {
e.code = rdp->errorInfo; context->LastError = MAKE_FREERDP_ERROR(ERRINFO, errorInfo);
PubSub_OnErrorInfo(context->pubSub, context, &e); if (context->pubSub)
{
ErrorInfoEventArgs e;
EventArgsInit(&e, "freerdp");
e.code = rdp->errorInfo;
PubSub_OnErrorInfo(context->pubSub, context, &e);
}
}
} }
else else
{ {