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
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

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