Preserve mask when copying wxBitmapRefData to avoid crashes
This crash was introduced in 2d15218c9d
and could happens inside wxBitmap::MSWBlendMaskWithAlpha() because the
code checked for a mask and alpha, but the mask could be lost after
AllocExclusive().
In practice, this happened e.g. when using 16-bit color as is the case
for Windows 7 Hyper-V VMs.
Closes https://github.com/wxWidgets/wxWidgets/pull/1695
This commit is contained in:
committed by
Vadim Zeitlin
parent
d52331046c
commit
bb14c5f69b
@@ -223,10 +223,6 @@ wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
|
|||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
// (deep) copy the mask if present
|
|
||||||
if (data.m_bitmapMask)
|
|
||||||
m_bitmapMask = new wxMask(*data.m_bitmapMask);
|
|
||||||
|
|
||||||
#if wxUSE_WXDIB
|
#if wxUSE_WXDIB
|
||||||
wxASSERT_MSG( !data.m_dib,
|
wxASSERT_MSG( !data.m_dib,
|
||||||
wxT("can't copy bitmap locked for raw access!") );
|
wxT("can't copy bitmap locked for raw access!") );
|
||||||
@@ -261,6 +257,11 @@ wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_WXDIB
|
#endif // wxUSE_WXDIB
|
||||||
|
|
||||||
|
// Ensure this is done after the block above otherwise if the color depth didn't match we'll lose the mask
|
||||||
|
// (deep) copy the mask if present
|
||||||
|
if (data.m_bitmapMask)
|
||||||
|
m_bitmapMask = new wxMask(*data.m_bitmapMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapRefData::Free()
|
void wxBitmapRefData::Free()
|
||||||
|
Reference in New Issue
Block a user