Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Tests/test_imagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ def test_transform_with_wrap() -> None:


def test_overflow_segfault() -> None:
# Some Pythons fail getting the argument as an integer, and it falls
# through to the sequence. Seeing this on 32-bit Windows.
with pytest.raises((TypeError, MemoryError)):
# post patch, this fails with a memory error
with pytest.raises((OverflowError, MemoryError)):
# post patch, this fails with a memory error on 64-bit
x = Evil()

# This fails due to the invalid malloc above,
Expand Down
15 changes: 9 additions & 6 deletions src/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,23 @@ PyPath_Create(PyObject *self, PyObject *args) {
Py_ssize_t count;
double *xy;

if (PyArg_ParseTuple(args, "n:Path", &count)) {
if (!PyArg_ParseTuple(args, "O", &data)) {
return NULL;
}
if (PyLong_Check(data)) {
/* number of vertices */
count = PyLong_AsSsize_t(data);
if (PyErr_Occurred()) {
return NULL;
}

xy = alloc_array(count);
if (!xy) {
return NULL;
}

} else {
/* sequence or other path */
PyErr_Clear();
if (!PyArg_ParseTuple(args, "O", &data)) {
return NULL;
}

count = PyPath_Flatten(data, &xy);
if (count < 0) {
return NULL;
Expand Down
Loading