savegame: initialise gym only when present #900
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #899.
Checklist
Description
The error message stemmed from the following line when it was being called against the legacy "Current Position" level object. During shutdown, it had
injections.length
value of 1 despite this being 0 when the gameflow was initially loaded, so it was trying to free a null injection path.https://github.com/LostArtefacts/Tomb1Main/blob/develop/src/game/gameflow.c#L1018
In
savegame.c
, the negative index in the initialisation just so happened to mean that the address of the length value above was being accessed, so it was changing from 0 to 1 here. This probably went unnoticed in pre-injection versions as it was most likely not changing anything that incurred memory management like we have in this situation.This is the only place where
g_GameFlow.gym_level_num
is used as an array index.