mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-12 09:12:22 +03:00
Catch incorrect palette sizes
This commit is contained in:
parent
4be146cf27
commit
2ec21cf5ae
|
@ -286,6 +286,7 @@ static const char* wrong_mode = "unrecognized image mode";
|
||||||
static const char* wrong_raw_mode = "unrecognized raw mode";
|
static const char* wrong_raw_mode = "unrecognized raw mode";
|
||||||
static const char* outside_image = "image index out of range";
|
static const char* outside_image = "image index out of range";
|
||||||
static const char* outside_palette = "palette index out of range";
|
static const char* outside_palette = "palette index out of range";
|
||||||
|
static const char* wrong_palette_size = "invalid palette size";
|
||||||
static const char* no_palette = "image has no palette";
|
static const char* no_palette = "image has no palette";
|
||||||
static const char* readonly = "image is readonly";
|
static const char* readonly = "image is readonly";
|
||||||
/* static const char* no_content = "image has no content"; */
|
/* static const char* no_content = "image has no content"; */
|
||||||
|
@ -1412,6 +1413,11 @@ _putpalette(ImagingObject* self, PyObject* args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( palettesize * 8 / bits > 256) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, wrong_palette_size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ImagingPaletteDelete(self->image->palette);
|
ImagingPaletteDelete(self->image->palette);
|
||||||
|
|
||||||
strcpy(self->image->mode, "P");
|
strcpy(self->image->mode, "P");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user