Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize datadir_path_value earlier in path_info #61555

Merged
merged 1 commit into from
Oct 9, 2022

Conversation

perryprog
Copy link
Contributor

Summary

None

Purpose of change

This seems to correct an edge case that I was running into that would cause prefix_path to get initialized to nothing, causing Cataclysm to crash with a segfault whenever I started it outside of the root of the repo. (macOS, CMake, release build, no odd build flags besides that.)

Cataclysm ran fine at the root of the git directory as there's the data/ sub-directory there, which is what CDDA would search for as gfxdir_path_value would end up being simply "data/" instead of the expected release value of "/usr/local/share/cataclysm-dda/" or similar. The crash itself probably occurs (instead of being caught within main.cpp) because the file exists checks worked fine since it was checking datadir_value, so the game assumed gfxdir_path_value was safe to use—I'm not to worried about this aspect of the issue, though, since this resolves the crash anyway.

Describe the solution

I moved the initialization of datadir_path_value to be earlier in PATH_INFO::set_standard_filenames.

Describe alternatives you've considered

None.

Testing

Building and running under CMake works without manually specifying --datadir (which uses a different code path to initialize datadir_path_value, and will end up working as-is)

Additional context

This looks like it was introduced as a part of d329307 in #50143, so hopefully @akrieger can take a look at this to make sure this fix is reasonable. I'm fairly certain there aren't any edge cases that I'm unable to check that this change breaks.

This seems to correct an edge case that I was running into that would cause
prefix_path to get initialized to nothing, causing Cataclysm to crash whenever I
started it outside of the root of the repo.

Cataclysm ran fine at the root of the git directory as there's the data/
sub-directory there, which is what CDDA would search for as gfxdir_path_value
would end up being simply "data/". The crash probably occurs because the file
exists checks worked fine since it was checking datadir_value, so the game
assumed gfxdir_path_value was safe to use.
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Oct 8, 2022
@NetSysFire NetSysFire added Code: Build Issues regarding different builds and build environments OS: macOS Issues related to macOS / OSX operating system labels Oct 8, 2022
Copy link
Member

@akrieger akrieger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find, thanks!

@dseguin dseguin merged commit 91310b2 into CleverRaven:master Oct 9, 2022
@perryprog perryprog deleted the pave-the-path branch October 9, 2022 00:37
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments json-styled JSON lint passed, label assigned by github actions OS: macOS Issues related to macOS / OSX operating system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants