It would then be incorrect for xy to be accessed again by path_map().
I've added a flag to PyPathObject that is set at the start of the mapping loop, and cleared at the end. If the user's custom Python function calls compact() to reallocate the array in the middle, then a ValueError is raised.
Within
path_map()
, a Python function is called. https://github.com/python-pillow/Pillow/blob/55a25aa4b1c91ae50ce29c13dffaa808a250ddbb/src/path.c#L393-L404That Python function could, theoretically, make a call to
ImagePath.Path.compact()
, akapath_compact()
, reallocatingself->xy
. https://github.com/python-pillow/Pillow/blob/55a25aa4b1c91ae50ce29c13dffaa808a250ddbb/src/path.c#L300It would then be incorrect for
xy
to be accessed again bypath_map()
.I've added a flag to
PyPathObject
that is set at the start of the mapping loop, and cleared at the end. If the user's custom Python function callscompact()
to reallocate the array in the middle, then aValueError
is raised.