From 85362020e3f1653c916dbe5cfc83e2b63eb30c5f Mon Sep 17 00:00:00 2001 From: Ken Keys Date: Fri, 5 Apr 2019 10:43:55 -0700 Subject: [PATCH] Fix memory leak in get_communities_pyset() affected all uses of the elem.fields dict --- src/_pybgpstream_bgpelem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/_pybgpstream_bgpelem.c b/src/_pybgpstream_bgpelem.c index 8e19f32..eaa824f 100644 --- a/src/_pybgpstream_bgpelem.c +++ b/src/_pybgpstream_bgpelem.c @@ -82,7 +82,9 @@ static PyObject *get_communities_pyset(bgpstream_community_set_t *communities) } /* add community to set */ - PySet_Add(set, PYSTR_FROMSTR(comm_buf)); + PyObject *pystr = PYSTR_FROMSTR(comm_buf); + PySet_Add(set, pystr); // does NOT steal reference + Py_DECREF(pystr); } return set; }