GUI/Field: Fix crash in color picker init (#2220)

wxButton->GetBitmap() may return an invalid wxBitmap.
Guard against this.
This commit is contained in:
mia 2023-09-25 17:38:13 +02:00 committed by GitHub
parent 3b864e562a
commit ec90d7f3e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1539,6 +1539,8 @@ void ColourPicker::set_undef_value(wxColourPickerCtrl* field)
field->SetColour(wxTransparentColour);
wxButton* btn = dynamic_cast<wxButton*>(field->GetPickerCtrl());
if (!btn->GetBitmap().IsOk()) return;
wxImage image(btn->GetBitmap().GetSize());
image.InitAlpha();
memset(image.GetAlpha(), 0, image.GetWidth() * image.GetHeight());