Fix: do not add an offset to a nullptr #8351
Conversation
Are there any additional changes (asserts, etc) that could be added to prevent this mistake from being made in future? |
Went for a slightly different direction; turns out there were more places that are or could potentially feed a |
And something is wrong: when saving the date,
This is caused by |
This is, by specs, undefined behaviour. See https://reviews.llvm.org/D67122 In cases where this is done, optimizations done by LLVM can generate code that causes crashes. GetVariableAddress() had two (legit) ways this could happen: - For SaveLoad set to global - For SaveLoad set to SLE_VAR_NULL, where sld->address is always a nullptr, and object could or could not be a nullptr.
This function is something. This patch changes the behaviour a bit: when a |
Everything about this bit of the code is horrifying, but I'm happy you've tested it well enough :) |
While at it, prevent a potential cases where an offset would be added to a
nullptr
(which would be horrible wrong for completely different reasons).Tnx to milek7 for tracing the root cause.