Skip to content

Update python versions in run-ubuntu-checks workflow, and fix faulty refcounting in rect clipline #3548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2025
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
5 changes: 3 additions & 2 deletions .github/workflows/run-ubuntu-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ jobs:
os: [ ubuntu-24.04 ]
# check our min python (minor) version and our max python (minor) version
python: [
3.9.21,
3.13.1
3.9.23,
3.13.5,
3.14.0rc1
]

env:
Expand Down
8 changes: 5 additions & 3 deletions src_c/rect_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,7 @@ RectExport_clip(RectObject *self, PyObject *const *args, Py_ssize_t nargs)
static PyObject *
RectExport_clipline(RectObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *outer_rect = NULL;
InnerRect *rect = &self->r, *rect_copy = NULL;
PrimitiveType x1, y1, x2, y2;

Expand Down Expand Up @@ -1918,7 +1919,8 @@ RectExport_clipline(RectObject *self, PyObject *const *args, Py_ssize_t nargs)

if ((self->r.w < 0) || (self->r.h < 0)) {
/* Make a copy of the rect so it can be normalized. */
rect_copy = &pgRectAsRect(RectExport_RectNew(&self->r));
outer_rect = RectExport_RectNew(&self->r);
rect_copy = &pgRectAsRect(outer_rect);

if (rect_copy == NULL) {
return RAISE(PyExc_MemoryError, "cannot allocate memory for rect");
Expand All @@ -1929,11 +1931,11 @@ RectExport_clipline(RectObject *self, PyObject *const *args, Py_ssize_t nargs)
}

if (!RectImport_IntersectRectAndLine(rect, &x1, &y1, &x2, &y2)) {
Py_XDECREF(rect_copy);
Py_XDECREF(outer_rect);
return PyTuple_New(0);
}

Py_XDECREF(rect_copy);
Py_XDECREF(outer_rect);

PyObject *subtup1, *subtup2;
subtup1 = TupleFromTwoPrimitives(x1, y1);
Expand Down
Loading