diff --git a/Tests/fonts/oom-4da0210eb7081b0bf15bf16cc4c52ce02c1e1bbc.ttf b/Tests/fonts/oom-4da0210eb7081b0bf15bf16cc4c52ce02c1e1bbc.ttf new file mode 100644 index 000000000..fe200842e Binary files /dev/null and b/Tests/fonts/oom-4da0210eb7081b0bf15bf16cc4c52ce02c1e1bbc.ttf differ diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 4a40d1d1d..7fa8ff8cb 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -1042,6 +1042,7 @@ def test_render_mono_size(): "test_file", [ "Tests/fonts/oom-e8e927ba6c0d38274a37c1567560eb33baf74627.ttf", + "Tests/fonts/oom-4da0210eb7081b0bf15bf16cc4c52ce02c1e1bbc.ttf", ], ) def test_oom(test_file): diff --git a/src/_imagingft.c b/src/_imagingft.c index 02d54fe23..d421e5a0b 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -880,7 +880,7 @@ font_render(FontObject *self, PyObject *args) { width += stroke_width * 2 + ceil(x_start); height += stroke_width * 2 + ceil(y_start); if (max_image_pixels != Py_None) { - if (width * height > PyLong_AsLong(max_image_pixels) * 2) { + if ((long long)width * height > PyLong_AsLong(max_image_pixels) * 2) { PyMem_Del(glyph_info); return Py_BuildValue("O(ii)(ii)", Py_None, width, height, 0, 0); }