Skip to content

Commit a89f82c

Browse files
committed
More leak fixes
1 parent 37153b2 commit a89f82c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

astrometry_extension/astrometry_extension.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ static PyObject* astrometry_extension_solver_solve(PyObject* self, PyObject* arg
596596
double ra = 0.0;
597597
double dec = 0.0;
598598
xyzarr2radecdeg(match->center, &ra, &dec);
599-
PyObject* index_id = PyLong_FromLong(match->index->indexid);
600599
if (match->index->starkd->tagalong == NULL) {
601600
match->index->starkd->tagalong = get_tagalong(match->index->starkd);
602601
}
@@ -605,8 +604,7 @@ static PyObject* astrometry_extension_solver_solve(PyObject* self, PyObject* arg
605604
PyObject* match_stars = PyTuple_New(match->nindex);
606605
for (int star_id_index = 0; star_id_index < match->nindex; ++star_id_index) {
607606
PyObject* key = PyTuple_New(2);
608-
Py_INCREF(index_id);
609-
PyTuple_SET_ITEM(key, 0, index_id);
607+
PyTuple_SET_ITEM(key, 0, PyLong_FromLong(match->index->indexid));
610608
PyTuple_SET_ITEM(key, 1, PyLong_FromLong(match->refstarid[star_id_index]));
611609
if (PyDict_GetItem(stars, key) == NULL) {
612610
PyObject* star = star_to_python_object(
@@ -630,21 +628,21 @@ static PyObject* astrometry_extension_solver_solve(PyObject* self, PyObject* arg
630628
if (query != NULL && query->nres > 0) {
631629
PyObject* key = PyTuple_New(2);
632630
Py_INCREF(index_id);
633-
PyTuple_SET_ITEM(key, 0, index_id);
631+
PyTuple_SET_ITEM(key, 0, PyLong_FromLong(match->index->indexid));
634632
PyTuple_SET_ITEM(key, 1, PyLong_FromLong(query->inds[0]));
635633
PyTuple_SET_ITEM(match_quad_stars, quad_index, key);
636634
if (PyDict_GetItem(stars, key) == NULL) {
637635
PyObject* star = star_to_python_object(
638636
match->index->starkd, query->inds[0], match->index->starkd->tagalong != NULL, columns, logging);
639637
PyDict_SetItem(stars, key, star);
638+
Py_DECREF(star);
640639
}
641640
} else {
642641
Py_INCREF(Py_None);
643642
PyTuple_SET_ITEM(match_quad_stars, quad_index, Py_None);
644643
}
645644
kdtree_free_query(query);
646645
}
647-
Py_DECREF(index_id);
648646
PyObject* wcs_fields = PyDict_New();
649647
add_wcs_field(wcs_fields, "WCSAXES", PyLong_FromLong(2), "Number of coordinate axes");
650648
add_wcs_field(wcs_fields, "EQUINOX", PyFloat_FromDouble(2000.0), "Equatorial coordinates definition (yr)");

0 commit comments

Comments
 (0)