Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 615c0dc

Browse files
committed
Fix reference counting
1 parent 0f809f8 commit 615c0dc

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/_image_wrapper.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
170170
}
171171

172172
py_is_affine2 = PyObject_IsTrue(py_is_affine);
173+
Py_DECREF(py_is_affine);
173174

174175
if (py_is_affine2 == -1) {
175176
goto error;
176-
} else if (py_is_affine2 == 1) {
177+
} else if (py_is_affine2) {
177178
if (!convert_trans_affine(py_transform, &params.affine)) {
178179
goto error;
179180
}
@@ -190,8 +191,10 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
190191
}
191192

192193
if (PyArray_NDIM(input_array) != PyArray_NDIM(output_array)) {
193-
PyErr_Format(PyExc_ValueError, "Mismatched number of dimensions. Got %d and %d.",
194-
PyArray_NDIM(input_array), PyArray_NDIM(output_array));
194+
PyErr_Format(
195+
PyExc_ValueError,
196+
"Mismatched number of dimensions. Got %d and %d.",
197+
PyArray_NDIM(input_array), PyArray_NDIM(output_array));
195198
goto error;
196199
}
197200

@@ -202,8 +205,9 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
202205

203206
if (PyArray_NDIM(input_array) == 3) {
204207
if (PyArray_DIM(output_array, 2) != 4) {
205-
PyErr_SetString(PyExc_ValueError,
206-
"Output array must be RGBA");
208+
PyErr_SetString(
209+
PyExc_ValueError,
210+
"Output array must be RGBA");
207211
goto error;
208212
}
209213

0 commit comments

Comments
 (0)