Fix potential bug in install checker

UB would occur if installer.CheckInstallLocation() failed when attempting to change the install location
This commit is contained in:
pizzaboxer 2024-09-09 12:09:44 +01:00
parent 62064117b6
commit 356155c75b
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 24 additions and 17 deletions

View File

@ -198,6 +198,26 @@ namespace Bloxstrap
}
}
if (fixInstallLocation && installLocation is not null)
{
var installer = new Installer
{
InstallLocation = installLocation,
IsImplicitInstall = true
};
if (installer.CheckInstallLocation())
{
Logger.WriteLine(LOG_IDENT, $"Changing install location to '{installLocation}'");
installer.DoInstall();
}
else
{
// force reinstall
installLocation = null;
}
}
if (installLocation is null)
{
Logger.Initialize(true);
@ -205,21 +225,6 @@ namespace Bloxstrap
}
else
{
if (fixInstallLocation)
{
var installer = new Installer
{
InstallLocation = installLocation,
IsImplicitInstall = true
};
if (installer.CheckInstallLocation())
{
Logger.WriteLine(LOG_IDENT, $"Changing install location to '{installLocation}'");
installer.DoInstall();
}
}
Paths.Initialize(installLocation);
// ensure executable is in the install directory
@ -246,10 +251,8 @@ namespace Bloxstrap
Locale.Set(Settings.Prop.Locale);
#if !DEBUG
if (!LaunchSettings.BypassUpdateCheck)
Installer.HandleUpgrade();
#endif
LaunchHandler.ProcessLaunchArgs();
}

View File

@ -28,7 +28,11 @@ namespace Bloxstrap
public LaunchFlag StudioFlag { get; } = new("studio");
#if DEBUG
public bool BypassUpdateCheck => true;
#else
public bool BypassUpdateCheck => UninstallFlag.Active || WatcherFlag.Active;
#endif
public LaunchMode RobloxLaunchMode { get; set; } = LaunchMode.None;