Fix nullptr deref in SaveButtons without an associated SaveFile

I've seen the nullptr deref, but I don't see how it's possible at all. A condition for file->LazyUnload to be called is for SaveButton::wantsDraw to be false, but for that to happen, SaveButton::Tick has to be called after a call to SaveButton::Draw to reset it to false, and then *again* for it to see it being false on entry.

Whatever, the bug is genuinely there and is bad, and easy to fix, no need to figure out in what way it is bad exactly.
This commit is contained in:
Tamás Bálint Misius
2022-12-15 07:35:15 +01:00
parent 2cd1f7bad3
commit 1beaebb928

View File

@@ -170,7 +170,7 @@ void SaveButton::Tick(float dt)
thumbSize = ui::Point(thumbnail->Width, thumbnail->Height); thumbSize = ui::Point(thumbnail->Width, thumbnail->Height);
} }
} }
if (!wantsDraw && !thumbnailRenderer) if (file && !wantsDraw && !thumbnailRenderer)
{ {
file->LazyUnload(); file->LazyUnload();
thumbnail.reset(); thumbnail.reset();