Skip to content

Commit

Permalink
Merge branch 'image_crash' of https://github.com/Randalphwa/wxWidgets
Browse files Browse the repository at this point in the history
Don't crash in wxImage::InitAlpha() if it's called on an empty image
and avoid calling it in this case.

See #24260.
  • Loading branch information
vadz committed Jan 28, 2024
2 parents fc35ad9 + 0255d8d commit f82ccc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/msw/imaglist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f82ccc1

Please sign in to comment.