Fix dereferencing a null pointer if SUNSHINE_MIGRATE_CONFIG doesn't exist

This commit is contained in:
Cameron Gutman
2024-03-14 18:37:00 -05:00
parent b523945f48
commit f66a7d5da6

View File

@@ -104,6 +104,7 @@ namespace platf {
bool migrate_config = true;
const char *dir;
const char *homedir;
const char *migrate_envvar;
fs::path config_path;
// Get the home directory
@@ -130,7 +131,8 @@ namespace platf {
}
// migrate from the old config location if necessary
if (migrate_config && found && getenv("SUNSHINE_MIGRATE_CONFIG") == "1"sv) {
migrate_envvar = getenv("SUNSHINE_MIGRATE_CONFIG");
if (migrate_config && found && migrate_envvar && strcmp(migrate_envvar, "1") == 0) {
fs::path old_config_path = fs::path(homedir) / ".config/sunshine"sv;
if (old_config_path != config_path && fs::exists(old_config_path)) {
if (!fs::exists(config_path)) {