From 4c4624a7f82c680870a92cda1a518184899b3243 Mon Sep 17 00:00:00 2001 From: Tim Dawborn Date: Mon, 28 Dec 2015 15:46:27 +1100 Subject: [PATCH] Corrected memory leak due to not decrementing the reference count of the list item being replaced. --- python/objToJSON.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/objToJSON.c b/python/objToJSON.c index a78f3c9..26b77be 100644 --- a/python/objToJSON.c +++ b/python/objToJSON.c @@ -554,7 +554,10 @@ int SortedDict_iterNext(JSOBJ obj, JSONTypeContext *tc) { goto error; } - PyList_SET_ITEM(items, i, item); + if (PyList_SetItem(items, i, item)) + { + goto error; + } Py_DECREF(key); }