Skip to content

Commit

Permalink
Fix potential bug in install checker
Browse files Browse the repository at this point in the history
UB would occur if installer.CheckInstallLocation() failed when attempting to change the install location
  • Loading branch information
pizzaboxer committed Sep 9, 2024
1 parent 6206411 commit 356155c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
37 changes: 20 additions & 17 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,33 @@ protected override void OnStartup(StartupEventArgs e)
}
}

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);
LaunchHandler.LaunchInstaller();
}
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
Expand All @@ -246,10 +251,8 @@ protected override void OnStartup(StartupEventArgs e)

Locale.Set(Settings.Prop.Locale);

#if !DEBUG
if (!LaunchSettings.BypassUpdateCheck)
Installer.HandleUpgrade();
#endif

LaunchHandler.ProcessLaunchArgs();
}
Expand Down
4 changes: 4 additions & 0 deletions Bloxstrap/LaunchSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public class LaunchSettings

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;

Expand Down

0 comments on commit 356155c

Please sign in to comment.