Skip to content

Commit

Permalink
check type given to ImageCms.core.profile_tobytes instead of crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Jan 1, 2024
1 parent 2945ef7 commit 02fd759
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Tests/test_imagecms.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ def test_profile_typesafety():
with pytest.raises(TypeError, match="Invalid type for Profile"):
ImageCms.ImageCmsProfile(1).tobytes()

# also check core function
with pytest.raises(TypeError):
ImageCms.core.profile_tobytes(0)
with pytest.raises(TypeError):
ImageCms.core.profile_tobytes(1)


def assert_aux_channel_preserved(mode, transform_in_place, preserved_channel):
def create_test_image():
Expand Down
2 changes: 1 addition & 1 deletion src/_imagingcms.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ cms_profile_tobytes(PyObject *self, PyObject *args) {
cmsHPROFILE *profile;

PyObject *ret;
if (!PyArg_ParseTuple(args, "O", &CmsProfile)) {
if (!PyArg_ParseTuple(args, "O!", &CmsProfile_Type, &CmsProfile)) {
return NULL;
}

Expand Down

0 comments on commit 02fd759

Please sign in to comment.