Skip to content

Commit

Permalink
increment Py_True/Py_False references before returning
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Jul 5, 2023
1 parent 8b23215 commit 29d963e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -3777,7 +3777,7 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op

// If the other object is not an ImagingObject.
if (!PyImaging_Check(other)) {
return op == Py_EQ ? Py_False : Py_True;
return Py_NewRef(op == Py_EQ ? Py_False : Py_True);
}

const Imaging img_a = self->image;
Expand All @@ -3788,7 +3788,7 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op
|| img_a->xsize != img_b->xsize
|| img_a->ysize != img_b->ysize
) {
return op == Py_EQ ? Py_False : Py_True;
return Py_NewRef(op == Py_EQ ? Py_False : Py_True);
}

const ImagingPalette palette_a = img_a->palette;
Expand All @@ -3810,20 +3810,22 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op
palette_b_data_ptr
)
) {
return op == Py_EQ ? Py_False : Py_True;
return Py_NewRef(op == Py_EQ ? Py_False : Py_True);
}
}

if (_compare_pixels(
if (
_compare_pixels(
img_a->mode,
img_a->ysize,
img_a->linesize,
(const UINT8 **)img_a->image,
(const UINT8 **)img_b->image)
(const UINT8 **)img_b->image
)
) {
return op == Py_EQ ? Py_False : Py_True;
return Py_NewRef(op == Py_EQ ? Py_False : Py_True);
} else {
return op == Py_EQ ? Py_True : Py_False;
return Py_NewRef(op == Py_EQ ? Py_True : Py_False);
}
}

Expand Down

0 comments on commit 29d963e

Please sign in to comment.