Skip to content

Commit

Permalink
fix a undefined behaviour for std::string and nullptr access
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-volz committed Mar 1, 2023
1 parent b2680af commit 036a839
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gameheaders/stratagus-game-launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ static void SetUserDataPath(char* data_path) {
}
strcat(data_path, "\\Stratagus\\");
#else
std::string appimage = std::string(getenv("APPIMAGE"));
char *appimage_ptr = getenv("APPIMAGE");
std::string appimage;
if (appimage_ptr != nullptr) {
appimage = std::string(appimage_ptr);
}
if (!appimage.empty() && fs::exists(fs::path(appimage))) {
if (fs::exists(fs::path(appimage + ".data"))) {
strcpy(data_path, (appimage + ".data/stratagus").c_str());
Expand Down

0 comments on commit 036a839

Please sign in to comment.