mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Avoid reading invalid images in doc::read_image()
This commit is contained in:
parent
8353e45ae8
commit
045ece4114
@ -99,6 +99,14 @@ Image* read_image(std::istream& is, bool setId)
|
||||
int height = read16(is); // Height
|
||||
uint32_t maskColor = read32(is); // Mask color
|
||||
|
||||
if ((pixelFormat != IMAGE_RGB &&
|
||||
pixelFormat != IMAGE_GRAYSCALE &&
|
||||
pixelFormat != IMAGE_INDEXED &&
|
||||
pixelFormat != IMAGE_BITMAP) ||
|
||||
(width < 1 || height < 1) ||
|
||||
(width > 0xfffff || height > 0xfffff))
|
||||
return nullptr;
|
||||
|
||||
base::UniquePtr<Image> image(Image::create(static_cast<PixelFormat>(pixelFormat), width, height));
|
||||
int rowSize = image->getRowStrideSize();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user