Skip to content

Commit 6f9da83

Browse files
committed
Fix Py_DECREF memory leak
1 parent bab4be8 commit 6f9da83

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def initialize_options(self):
5151
depends=depends,
5252
py_limited_api=True,
5353
define_macros=[
54-
('Py_LIMITED_API', '0x03020000'),
5554
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
5655
# ('DBSCAN_VERSION', json.dumps(version)),
5756
]

src/dbscanmodule.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ static PyObject* DBSCAN_py(PyObject* self, PyObject* args, PyObject *kwargs)
7171
);
7272

7373
parlay::internal::stop_scheduler();
74-
75-
return PyTuple_Pack(2, labels, core_samples);
74+
75+
PyObject* result_tuple = PyTuple_Pack(2, labels, core_samples);
76+
Py_DECREF(X);
77+
Py_DECREF(core_samples);
78+
Py_DECREF(labels);
79+
return result_tuple;
7680
}
7781

7882
PyDoc_STRVAR(doc_DBSCAN,

0 commit comments

Comments
 (0)