summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--simplejson/_speedups.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c
index 7b46d8a..e4620b5 100644
--- a/simplejson/_speedups.c
+++ b/simplejson/_speedups.c
@@ -692,7 +692,8 @@ encoder_dict_iteritems(PyEncoderObject *s, PyObject *dct)
PyObject *lst = NULL;
PyObject *item = NULL;
PyObject *kstr = NULL;
- static PyObject *sortfun = NULL;
+ PyObject *sortfun = NULL;
+ PyObject *sortres;
static PyObject *sortargs = NULL;
if (sortargs == NULL) {
@@ -763,8 +764,10 @@ encoder_dict_iteritems(PyEncoderObject *s, PyObject *dct)
sortfun = PyObject_GetAttrString(lst, "sort");
if (sortfun == NULL)
goto bail;
- if (!PyObject_Call(sortfun, sortargs, s->item_sort_kw))
+ sortres = PyObject_Call(sortfun, sortargs, s->item_sort_kw);
+ if (!sortres)
goto bail;
+ Py_DECREF(sortres);
Py_CLEAR(sortfun);
iter = PyObject_GetIter(lst);
Py_CLEAR(lst);