Return a PyError instead of a fake fterror.

* Update Tests to IOError rather than OSError
This commit is contained in:
Eric Soroos 2022-11-03 21:26:17 +01:00 committed by Andrew Murray
parent f2b36a1833
commit 1c57ab8429
3 changed files with 5 additions and 3 deletions

View File

@ -57,6 +57,8 @@ def test_fuzz_fonts(path):
with open(path, "rb") as f:
try:
fuzzers.fuzz_font(f.read())
except (Image.DecompressionBombError, Image.DecompressionBombWarning):
except (Image.DecompressionBombError,
Image.DecompressionBombWarning,
IOError):
pass
assert True

View File

@ -17,6 +17,6 @@ class TestFontCrash:
@skip_unless_feature("freetype2")
def test_segfault(self):
with pytest.raises(OSError):
with pytest.raises(IOError):
font = ImageFont.truetype("Tests/fonts/fuzz_font-5203009437302784")
self._fuzz_font(font)

View File

@ -923,7 +923,7 @@ font_render(FontObject *self, PyObject *args) {
// Null buffer, is dereferenced in FT_Bitmap_Convert
if (!bitmap.buffer && bitmap.rows) {
return geterror(0x9D); // Bitmap missing
PyErr_SetString(PyExc_IOError, "Bitmap missing for glyph");
goto glyph_error;
}