Skip to content

Commit a23b9c1

Browse files
authored
Merge pull request #662 from benjeffery/pop-mem-leak
Fix memory leak in population table get row
2 parents c7c89c1 + ea0bc2b commit a23b9c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/_tskitmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,12 @@ make_population(tsk_population_t *population)
326326
PyObject *ret = NULL;
327327
PyObject *metadata = make_metadata(population->metadata,
328328
(Py_ssize_t) population->metadata_length);
329-
329+
if (metadata == NULL) {
330+
goto out;
331+
}
330332
ret = Py_BuildValue("(O)", metadata);
333+
out:
334+
Py_XDECREF(metadata);
331335
return ret;
332336
}
333337

0 commit comments

Comments
 (0)