Don't crash in wxImage::InitAlpha() if it's called on an empty image
and avoid calling it in this case.

See #24260.
This commit is contained in:
Vadim Zeitlin 2024-01-28 18:18:14 +01:00
commit f82ccc1a19
2 changed files with 8 additions and 0 deletions

View file

@ -2185,6 +2185,8 @@ unsigned char *wxImage::GetAlpha() const
void wxImage::InitAlpha()
{
wxCHECK_RET( IsOk(), wxT("invalid image") );
wxCHECK_RET( !HasAlpha(), wxT("image already has an alpha channel") );
// initialize memory for alpha channel

View file

@ -167,6 +167,12 @@ void
wxImageList::GetImageListBitmaps(wxMSWBitmaps& bitmaps,
const wxBitmap& bitmap, const wxBitmap& mask)
{
if (!bitmap.IsOk())
{
// We can't do anything with an invalid bitmap.
return;
}
// This can be overwritten below if we need to modify the bitmap, but it
// doesn't cost anything to initialize the bitmap with this HBITMAP.
bitmaps.hbmp = GetHbitmapOf(bitmap);