##// END OF EJS Templates
parsers: avoid leaking several PyObjects in index_stats...
Augie Fackler -
r23948:bd307b46 stable
parent child Browse files
Show More
@@ -818,19 +818,27 static PyObject *index_clearcaches(index
818 818 static PyObject *index_stats(indexObject *self)
819 819 {
820 820 PyObject *obj = PyDict_New();
821 PyObject *t = NULL;
821 822
822 823 if (obj == NULL)
823 824 return NULL;
824 825
825 826 #define istat(__n, __d) \
826 if (PyDict_SetItemString(obj, __d, PyInt_FromSsize_t(self->__n)) == -1) \
827 goto bail;
827 t = PyInt_FromSsize_t(self->__n); \
828 if (!t) \
829 goto bail; \
830 if (PyDict_SetItemString(obj, __d, t) == -1) \
831 goto bail; \
832 Py_DECREF(t);
828 833
829 834 if (self->added) {
830 835 Py_ssize_t len = PyList_GET_SIZE(self->added);
831 if (PyDict_SetItemString(obj, "index entries added",
832 PyInt_FromSsize_t(len)) == -1)
836 t = PyInt_FromSsize_t(len);
837 if (!t)
833 838 goto bail;
839 if (PyDict_SetItemString(obj, "index entries added", t) == -1)
840 goto bail;
841 Py_DECREF(t);
834 842 }
835 843
836 844 if (self->raw_length != self->length - 1)
@@ -850,6 +858,7 static PyObject *index_stats(indexObject
850 858
851 859 bail:
852 860 Py_XDECREF(obj);
861 Py_XDECREF(t);
853 862 return NULL;
854 863 }
855 864
General Comments 0
You need to be logged in to leave comments. Login now