##// 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 b' static PyObject *index_clearcaches(index'
818 static PyObject *index_stats(indexObject *self)
818 static PyObject *index_stats(indexObject *self)
819 {
819 {
820 PyObject *obj = PyDict_New();
820 PyObject *obj = PyDict_New();
821 PyObject *t = NULL;
821
822
822 if (obj == NULL)
823 if (obj == NULL)
823 return NULL;
824 return NULL;
824
825
825 #define istat(__n, __d) \
826 #define istat(__n, __d) \
826 if (PyDict_SetItemString(obj, __d, PyInt_FromSsize_t(self->__n)) == -1) \
827 t = PyInt_FromSsize_t(self->__n); \
827 goto bail;
828 if (!t) \
829 goto bail; \
830 if (PyDict_SetItemString(obj, __d, t) == -1) \
831 goto bail; \
832 Py_DECREF(t);
828
833
829 if (self->added) {
834 if (self->added) {
830 Py_ssize_t len = PyList_GET_SIZE(self->added);
835 Py_ssize_t len = PyList_GET_SIZE(self->added);
831 if (PyDict_SetItemString(obj, "index entries added",
836 t = PyInt_FromSsize_t(len);
832 PyInt_FromSsize_t(len)) == -1)
837 if (!t)
833 goto bail;
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 if (self->raw_length != self->length - 1)
844 if (self->raw_length != self->length - 1)
@@ -850,6 +858,7 b' static PyObject *index_stats(indexObject'
850
858
851 bail:
859 bail:
852 Py_XDECREF(obj);
860 Py_XDECREF(obj);
861 Py_XDECREF(t);
853 return NULL;
862 return NULL;
854 }
863 }
855
864
General Comments 0
You need to be logged in to leave comments. Login now