From f66a7d5da65a00d5b8cb8aed79169b67be9c1076 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 14 Mar 2024 18:37:00 -0500 Subject: [PATCH] Fix dereferencing a null pointer if SUNSHINE_MIGRATE_CONFIG doesn't exist --- src/platform/linux/misc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platform/linux/misc.cpp b/src/platform/linux/misc.cpp index 884c0e90..b4de6005 100644 --- a/src/platform/linux/misc.cpp +++ b/src/platform/linux/misc.cpp @@ -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)) {