Fix #2111: Add nullptr check before using the order object#2127
Fix #2111: Add nullptr check before using the order object#2127AaronVanGeffen merged 3 commits intoOpenLoco:masterfrom
Conversation
| auto orderRing = Vehicles::OrderRingView(orderFrame.orderOffset); | ||
| auto* order = orderRing.atIndex(0); | ||
| if (!order->hasFlags(Vehicles::OrderFlags::HasNumber)) | ||
| if (!order || !order->hasFlags(Vehicles::OrderFlags::HasNumber)) |
There was a problem hiding this comment.
I think this hides the issue rather than addressing it. Why is order a nullptr in the first place? The code assumes that there is an order to display, so why isn't there?
There was a problem hiding this comment.
Hi, yes I understand the problem a bit better now. I am still figuring out the issue.
Thank you
There was a problem hiding this comment.
Although it does hide the issue i tried to find the source before and wasn't successful. So if you can't work it out it doesn't matter we can just merge this
There was a problem hiding this comment.
Suggest we add a comment that we don't know why we can get into a bad state here but if we do then this makes it safe.
There was a problem hiding this comment.
Found the source of the issue. I'll keep this PR but augment it with an additional fix.
2b65f4e to
b7fa0c5
Compare
Fixes #2111