##// END OF EJS Templates
manifest: fix possible SEGV caused by uninitialized lazymanifest fields...
Yuya Nishihara -
r38346:ae7f2786 stable
parent child Browse files
Show More
@@ -135,12 +135,22 b' static int find_lines(lazymanifest *self'
135 return 0;
135 return 0;
136 }
136 }
137
137
138 static void lazymanifest_init_early(lazymanifest *self)
139 {
140 self->pydata = NULL;
141 self->lines = NULL;
142 self->numlines = 0;
143 self->maxlines = 0;
144 }
145
138 static int lazymanifest_init(lazymanifest *self, PyObject *args)
146 static int lazymanifest_init(lazymanifest *self, PyObject *args)
139 {
147 {
140 char *data;
148 char *data;
141 Py_ssize_t len;
149 Py_ssize_t len;
142 int err, ret;
150 int err, ret;
143 PyObject *pydata;
151 PyObject *pydata;
152
153 lazymanifest_init_early(self);
144 if (!PyArg_ParseTuple(args, "S", &pydata)) {
154 if (!PyArg_ParseTuple(args, "S", &pydata)) {
145 return -1;
155 return -1;
146 }
156 }
@@ -668,6 +678,7 b' static lazymanifest *lazymanifest_copy(l'
668 if (!copy) {
678 if (!copy) {
669 goto nomem;
679 goto nomem;
670 }
680 }
681 lazymanifest_init_early(copy);
671 copy->numlines = self->numlines;
682 copy->numlines = self->numlines;
672 copy->livelines = self->livelines;
683 copy->livelines = self->livelines;
673 copy->dirty = false;
684 copy->dirty = false;
@@ -705,6 +716,7 b' static lazymanifest *lazymanifest_filter'
705 if (!copy) {
716 if (!copy) {
706 goto nomem;
717 goto nomem;
707 }
718 }
719 lazymanifest_init_early(copy);
708 copy->dirty = true;
720 copy->dirty = true;
709 copy->lines = malloc(self->maxlines * sizeof(line));
721 copy->lines = malloc(self->maxlines * sizeof(line));
710 if (!copy->lines) {
722 if (!copy->lines) {
General Comments 0
You need to be logged in to leave comments. Login now