mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-21 16:20:53 +00:00
Fix problems loading .ico files with color_count=0, and images with pixels out of range.
This commit is contained in:
parent
06be16ad59
commit
8e007e9ca5
@ -118,7 +118,7 @@ static bool load_ICO(FileOp *fop)
|
||||
const ICONDIRENTRY& entry = entries[0];
|
||||
int width = (entry.width == 0 ? 256: entry.width);
|
||||
int height = (entry.height == 0 ? 256: entry.height);
|
||||
int numcolors = 1 << entry.bpp;
|
||||
int numcolors = (entry.color_count == 0 ? 256: entry.color_count);
|
||||
int imgtype = IMAGE_INDEXED;
|
||||
if (entry.bpp > 8)
|
||||
imgtype = IMAGE_RGB;
|
||||
@ -176,7 +176,11 @@ static bool load_ICO(FileOp *fop)
|
||||
|
||||
case 8:
|
||||
c = fgetc(f);
|
||||
image_putpixel(image, x, y, c);
|
||||
ASSERT(c >= 0 && c < numcolors);
|
||||
if (c >= 0 && c < numcolors)
|
||||
image_putpixel(image, x, y, c);
|
||||
else
|
||||
image_putpixel(image, x, y, 0);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
|
Loading…
x
Reference in New Issue
Block a user