You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've investigated a bit and founf that it's caused by the pgLine_FromObject function, responsible for extracting a Line struct from a single object. Issue is that both rect and Polygon count as Sequences, that are then treated in that function with this piece of code:
if (PySequence_Check(obj)) {
length=PySequence_Length(obj);
if (length==4) {
PyObject*tmp;
tmp=PySequence_GetItem(obj, 0);
if (!pg_DoubleFromObj(tmp, &(out->x1))) {
Py_DECREF(tmp);
return0;
}
Py_DECREF(tmp);
tmp=PySequence_GetItem(obj, 1);
if (!pg_DoubleFromObj(tmp, &(out->y1))) {
Py_DECREF(tmp);
return0;
}
Py_DECREF(tmp);
tmp=PySequence_GetItem(obj, 2);
if (!pg_DoubleFromObj(tmp, &(out->x2))) {
Py_DECREF(tmp);
return0;
}
Py_DECREF(tmp);
tmp=PySequence_GetItem(obj, 3);
if (!pg_DoubleFromObj(tmp, &(out->y2))) {
Py_DECREF(tmp);
return0;
}
Py_DECREF(tmp);
returnIS_LINE_VALID(out);
}
...
So when the sequence has length 4 (that are exactly the rect and Polygon with 4 vertices cases) issues arise
The text was updated successfully, but these errors were encountered:
While working on #194 i discovered two major issues.
The first one is that you can create a
Line
object from aRect
This is not fine as any function that takes in a Line or Line-like object also accepts a Rect. I don't think we should support this behaviour.
The second thing is that doing the same with a Polygon with 4 vertices results in a segfault:
I've investigated a bit and founf that it's caused by the
pgLine_FromObject
function, responsible for extracting a Line struct from a single object. Issue is that both rect and Polygon count as Sequences, that are then treated in that function with this piece of code:So when the sequence has length 4 (that are exactly the rect and Polygon with 4 vertices cases) issues arise
The text was updated successfully, but these errors were encountered: