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

Fix game load crash with unattached hyperspace clouds #4555

Merged
merged 2 commits into from Mar 7, 2019

Conversation

Projects
None yet
3 participants
@jaj22
Copy link
Contributor

commented Mar 6, 2019

Fixes #4552, maybe.

When loading a saved game with an HS cloud that doesn't have an attached ship, the m_ship pointer is unintialized, causing an immediate crash in MSVC debug and undefined behaviour everywhere else. This patch sets the value of m_ship to 0 in this case.

@fluffyfreak fluffyfreak self-requested a review Mar 6, 2019

@@ -44,6 +44,7 @@ HyperspaceCloud::HyperspaceCloud(const Json &jsonObj, Space *space) :
m_due = hyperspaceCloudObj["due"];
m_isArrival = hyperspaceCloudObj["is_arrival"];

m_ship = 0;

This comment has been minimized.

Copy link
@fluffyfreak

fluffyfreak Mar 6, 2019

Contributor

This should be nullptr rather than 0 which we're trying to discourage usage of.

@fluffyfreak

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2019

Cool, i'll either merge this and change it to nullptr or you can push the change.

@impaktor

This comment has been minimized.

Copy link
Member

commented Mar 7, 2019

@fluffyfreak then please do:
2019-03-07-090638_331x279_scrot

@fluffyfreak fluffyfreak merged commit 288f363 into pioneerspacesim:master Mar 7, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@impaktor

This comment has been minimized.

Copy link
Member

commented Mar 7, 2019

👍 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.