Don't return a valid image from wxImageList if its index is out of range

This commit is contained in:
Artur Wieczorek 2021-04-04 21:00:05 +02:00
parent d6443e65ee
commit 882f0a4631

View File

@ -405,7 +405,9 @@ wxBitmap wxImageList::GetBitmap(int index) const
if ( ii.hbmMask ) if ( ii.hbmMask )
{ {
// draw it the first time to find a suitable mask colour // draw it the first time to find a suitable mask colour
const_cast<wxImageList*>(this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT); if ( !const_cast<wxImageList*>(this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT) )
return wxNullBitmap;
dc.SelectObject(wxNullBitmap); dc.SelectObject(wxNullBitmap);
// find the suitable mask colour // find the suitable mask colour
@ -431,7 +433,9 @@ wxBitmap wxImageList::GetBitmap(int index) const
else // no mask else // no mask
{ {
// Just draw it normally. // Just draw it normally.
const_cast<wxImageList*>(this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL); if ( !const_cast<wxImageList*>(this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL) )
return wxNullBitmap;
dc.SelectObject(wxNullBitmap); dc.SelectObject(wxNullBitmap);
// And adjust its alpha flag as the destination bitmap would get it if // And adjust its alpha flag as the destination bitmap would get it if