Show More
@@ -1718,6 +1718,15 static int index_init(indexObject *self, | |||||
1718 | PyObject *data_obj, *inlined_obj; |
|
1718 | PyObject *data_obj, *inlined_obj; | |
1719 | Py_ssize_t size; |
|
1719 | Py_ssize_t size; | |
1720 |
|
1720 | |||
|
1721 | /* Initialize before argument-checking to avoid index_dealloc() crash. */ | |||
|
1722 | self->raw_length = 0; | |||
|
1723 | self->added = NULL; | |||
|
1724 | self->cache = NULL; | |||
|
1725 | self->data = NULL; | |||
|
1726 | self->headrevs = NULL; | |||
|
1727 | self->nt = NULL; | |||
|
1728 | self->offsets = NULL; | |||
|
1729 | ||||
1721 | if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj)) |
|
1730 | if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj)) | |
1722 | return -1; |
|
1731 | return -1; | |
1723 | if (!PyString_Check(data_obj)) { |
|
1732 | if (!PyString_Check(data_obj)) { | |
@@ -1728,12 +1737,7 static int index_init(indexObject *self, | |||||
1728 |
|
1737 | |||
1729 | self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj); |
|
1738 | self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj); | |
1730 | self->data = data_obj; |
|
1739 | self->data = data_obj; | |
1731 | self->cache = NULL; |
|
|||
1732 |
|
1740 | |||
1733 | self->added = NULL; |
|
|||
1734 | self->headrevs = NULL; |
|
|||
1735 | self->offsets = NULL; |
|
|||
1736 | self->nt = NULL; |
|
|||
1737 | self->ntlength = self->ntcapacity = 0; |
|
1741 | self->ntlength = self->ntcapacity = 0; | |
1738 | self->ntdepth = self->ntsplits = 0; |
|
1742 | self->ntdepth = self->ntsplits = 0; | |
1739 | self->ntlookups = self->ntmisses = 0; |
|
1743 | self->ntlookups = self->ntmisses = 0; | |
@@ -1769,7 +1773,7 static PyObject *index_nodemap(indexObje | |||||
1769 | static void index_dealloc(indexObject *self) |
|
1773 | static void index_dealloc(indexObject *self) | |
1770 | { |
|
1774 | { | |
1771 | _index_clearcaches(self); |
|
1775 | _index_clearcaches(self); | |
1772 | Py_DECREF(self->data); |
|
1776 | Py_XDECREF(self->data); | |
1773 | Py_XDECREF(self->added); |
|
1777 | Py_XDECREF(self->added); | |
1774 | PyObject_Del(self); |
|
1778 | PyObject_Del(self); | |
1775 | } |
|
1779 | } |
@@ -98,6 +98,14 def parse_index2(data, inline): | |||||
98 | return list(index), chunkcache |
|
98 | return list(index), chunkcache | |
99 |
|
99 | |||
100 | def runtest() : |
|
100 | def runtest() : | |
|
101 | # Check that parse_index2() raises TypeError on bad arguments. | |||
|
102 | try: | |||
|
103 | parse_index2(0, True) | |||
|
104 | except TypeError: | |||
|
105 | pass | |||
|
106 | else: | |||
|
107 | print "Expected to get TypeError." | |||
|
108 | ||||
101 | py_res_1 = py_parseindex(data_inlined, True) |
|
109 | py_res_1 = py_parseindex(data_inlined, True) | |
102 | c_res_1 = parse_index2(data_inlined, True) |
|
110 | c_res_1 = parse_index2(data_inlined, True) | |
103 |
|
111 |
General Comments 0
You need to be logged in to leave comments.
Login now