Fix XImage assignment operator in case other is empty.

This commit is contained in:
Jief L 2020-03-31 00:28:12 +03:00
parent 35103e3126
commit cdf5913c24

View File

@ -59,10 +59,13 @@ EFI_STATUS XImage::FromEGImage(const EG_IMAGE* egImage)
XImage& XImage::operator= (const XImage& other)
{
// Width = other.GetWidth();
// Height = other.GetHeight();
// &other.PixelData[0] won't work if other is empty. So we check.
if ( other.isEmpty() ) {
setEmpty();
}else{
setSizeInPixels(other.GetWidth(), other.GetHeight()); // change the size, ie the number of element in the array. Reaalocate buffer if needed
CopyMem(&PixelData[0], &other.PixelData[0], GetSizeInBytes());
}
return *this;
}