Fix memory leaks if parsed multiple times.
This commit is contained in:
parent
f0cc927359
commit
36241ed540
@ -1474,6 +1474,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
|
||||
CommandLineSwitchCase(arg, "v")
|
||||
{
|
||||
free (settings->ServerHostname);
|
||||
p = strchr(arg->Value, '[');
|
||||
/* ipv4 */
|
||||
if (!p)
|
||||
@ -1515,6 +1516,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "spn-class")
|
||||
{
|
||||
free (settings->AuthenticationServiceClass);
|
||||
if (!(settings->AuthenticationServiceClass = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
@ -1531,6 +1533,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
||||
{
|
||||
settings->SendPreconnectionPdu = TRUE;
|
||||
free (settings->PreconnectionBlob);
|
||||
if (!(settings->PreconnectionBlob = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -1622,6 +1625,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "t")
|
||||
{
|
||||
free (settings->WindowTitle);
|
||||
if (!(settings->WindowTitle = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -1663,11 +1667,13 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
{
|
||||
settings->ConsoleSession = TRUE;
|
||||
settings->RestrictedAdminModeRequired = TRUE;
|
||||
free (settings->PasswordHash);
|
||||
if (!(settings->PasswordHash = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "client-hostname")
|
||||
{
|
||||
free (settings->ClientHostname);
|
||||
if (!(settings->ClientHostname = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -1715,16 +1721,19 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "d")
|
||||
{
|
||||
free (settings->Domain);
|
||||
if (!(settings->Domain = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "p")
|
||||
{
|
||||
free (settings->Password);
|
||||
if (!(settings->Password = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "g")
|
||||
{
|
||||
free (settings->GatewayHostname);
|
||||
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
||||
{
|
||||
p = strchr(arg->Value, ':');
|
||||
@ -1764,12 +1773,14 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gd")
|
||||
{
|
||||
free (settings->GatewayDomain);
|
||||
if (!(settings->GatewayDomain = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
settings->GatewayUseSameCredentials = FALSE;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gp")
|
||||
{
|
||||
free (settings->GatewayPassword);
|
||||
if (!(settings->GatewayPassword = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
settings->GatewayUseSameCredentials = FALSE;
|
||||
@ -1815,6 +1826,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app")
|
||||
{
|
||||
free (settings->RemoteApplicationProgram);
|
||||
if (!(settings->RemoteApplicationProgram = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
@ -1826,33 +1838,39 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "load-balance-info")
|
||||
{
|
||||
free (settings->LoadBalanceInfo);
|
||||
if (!(settings->LoadBalanceInfo = (BYTE*) _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
settings->LoadBalanceInfoLength = (UINT32) strlen((char*) settings->LoadBalanceInfo);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-name")
|
||||
{
|
||||
free (settings->RemoteApplicationName);
|
||||
if (!(settings->RemoteApplicationName = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-icon")
|
||||
{
|
||||
free (settings->RemoteApplicationIcon);
|
||||
if (!(settings->RemoteApplicationIcon = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-cmd")
|
||||
{
|
||||
free (settings->RemoteApplicationCmdLine);
|
||||
if (!(settings->RemoteApplicationCmdLine = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-file")
|
||||
{
|
||||
free (settings->RemoteApplicationFile);
|
||||
if (!(settings->RemoteApplicationFile = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-guid")
|
||||
{
|
||||
free (settings->RemoteApplicationGuid);
|
||||
if (!(settings->RemoteApplicationGuid = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -1878,11 +1896,13 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "shell")
|
||||
{
|
||||
free (settings->AlternateShell);
|
||||
if (!(settings->AlternateShell = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "shell-dir")
|
||||
{
|
||||
free (settings->ShellWorkingDirectory);
|
||||
if (!(settings->ShellWorkingDirectory = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -2037,6 +2057,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
CommandLineSwitchCase(arg, "pcb")
|
||||
{
|
||||
settings->SendPreconnectionPdu = TRUE;
|
||||
free (settings->PreconnectionBlob);
|
||||
if (!(settings->PreconnectionBlob = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -2141,6 +2162,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "tls-ciphers")
|
||||
{
|
||||
free (settings->AllowedTlsCiphers);
|
||||
if (strcmp(arg->Value, "netmon") == 0)
|
||||
{
|
||||
if (!(settings->AllowedTlsCiphers = _strdup("ALL:!ECDH")))
|
||||
@ -2159,6 +2181,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "cert-name")
|
||||
{
|
||||
free (settings->CertificateName);
|
||||
if (!(settings->CertificateName = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -2253,11 +2276,13 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "wm-class")
|
||||
{
|
||||
free (settings->WmClass);
|
||||
if (!(settings->WmClass = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "play-rfx")
|
||||
{
|
||||
free (settings->PlayRemoteFxFile);
|
||||
if (!(settings->PlayRemoteFxFile = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
settings->PlayRemoteFx = TRUE;
|
||||
@ -2293,6 +2318,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
CommandLineSwitchCase(arg, "assistance")
|
||||
{
|
||||
settings->RemoteAssistanceMode = TRUE;
|
||||
free (settings->RemoteAssistancePassword);
|
||||
if (!(settings->RemoteAssistancePassword = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
@ -2353,9 +2379,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
|
||||
free (settings->Username);
|
||||
if (!settings->Domain && user)
|
||||
{
|
||||
BOOL ret;
|
||||
free (settings->Domain);
|
||||
|
||||
ret = freerdp_parse_username(user, &settings->Username, &settings->Domain);
|
||||
free(user);
|
||||
if (!ret)
|
||||
@ -2364,9 +2393,11 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
else
|
||||
settings->Username = user;
|
||||
|
||||
free (settings->GatewayUsername);
|
||||
if (!settings->GatewayDomain && gwUser)
|
||||
{
|
||||
BOOL ret;
|
||||
free (settings->GatewayDomain);
|
||||
ret = freerdp_parse_username(gwUser, &settings->GatewayUsername,
|
||||
&settings->GatewayDomain);
|
||||
free(gwUser);
|
||||
|
Loading…
Reference in New Issue
Block a user