diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index 3a3ddb75b..37470d580 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -103,21 +103,30 @@ int rdp_redirection_apply_settings(rdpRdp* rdp) } else { - if (settings->RedirectionFlags & LB_TARGET_FQDN) - { - free(settings->RedirectionTargetFQDN); - settings->RedirectionTargetFQDN = _strdup(redirection->TargetFQDN); - } - else if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS) - { - free(settings->TargetNetAddress); - settings->TargetNetAddress = _strdup(redirection->TargetNetAddress); - } - else if (settings->RedirectionFlags & LB_TARGET_NETBIOS_NAME) - { - free(settings->RedirectionTargetNetBiosName); - settings->RedirectionTargetNetBiosName = _strdup(redirection->TargetNetBiosName); - } + /** + * Free previous LoadBalanceInfo, if any, otherwise it may end up + * being reused for the redirected session, which is not what we want. + */ + + free(settings->LoadBalanceInfo); + settings->LoadBalanceInfo = NULL; + settings->LoadBalanceInfoLength = 0; + } + + if (settings->RedirectionFlags & LB_TARGET_FQDN) + { + free(settings->RedirectionTargetFQDN); + settings->RedirectionTargetFQDN = _strdup(redirection->TargetFQDN); + } + else if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS) + { + free(settings->TargetNetAddress); + settings->TargetNetAddress = _strdup(redirection->TargetNetAddress); + } + else if (settings->RedirectionFlags & LB_TARGET_NETBIOS_NAME) + { + free(settings->RedirectionTargetNetBiosName); + settings->RedirectionTargetNetBiosName = _strdup(redirection->TargetNetBiosName); } if (settings->RedirectionFlags & LB_USERNAME)