Avoid illegal memory access problem with 1 color paletted png(#73),
Thanks to HongxuChen.
@@ -284,9 +284,13 @@ sixel_dither_new(
quality_mode = SIXEL_QUALITY_HIGHCOLOR;
} else {
if (ncolors > SIXEL_PALETTE_MAX) {
+ status = SIXEL_BAD_INPUT;
ncolors = 256;
- } else if (ncolors < 2) {
- ncolors = 2;
+ } else if (ncolors < 1) {
+ status = SIXEL_BAD_INPUT;
+ sixel_helper_set_additional_message(
+ "sixel_dither_new: palette colors must be more than 0");
+ goto end;
}
quality_mode = SIXEL_QUALITY_LOW;
}
