equal
deleted
inserted
replaced
49 /* get the node value of a single line */ |
49 /* get the node value of a single line */ |
50 static PyObject *nodeof(line *l) |
50 static PyObject *nodeof(line *l) |
51 { |
51 { |
52 char *s = l->start; |
52 char *s = l->start; |
53 ssize_t llen = pathlen(l); |
53 ssize_t llen = pathlen(l); |
54 PyObject *hash = unhexlify(s + llen + 1, 40); |
54 PyObject *hash; |
|
55 if (llen + 1 + 40 + 1 > l->len) { /* path '\0' hash '\n' */ |
|
56 PyErr_SetString(PyExc_ValueError, "manifest line too short"); |
|
57 return NULL; |
|
58 } |
|
59 hash = unhexlify(s + llen + 1, 40); |
55 if (!hash) { |
60 if (!hash) { |
56 return NULL; |
61 return NULL; |
57 } |
62 } |
58 if (l->hash_suffix != '\0') { |
63 if (l->hash_suffix != '\0') { |
59 char newhash[21]; |
64 char newhash[21]; |
247 goto done; |
252 goto done; |
248 } |
253 } |
249 pl = pathlen(l); |
254 pl = pathlen(l); |
250 path = PyBytes_FromStringAndSize(l->start, pl); |
255 path = PyBytes_FromStringAndSize(l->start, pl); |
251 hash = nodeof(l); |
256 hash = nodeof(l); |
|
257 if (!path || !hash) { |
|
258 goto done; |
|
259 } |
252 consumed = pl + 41; |
260 consumed = pl + 41; |
253 flags = PyBytes_FromStringAndSize(l->start + consumed, |
261 flags = PyBytes_FromStringAndSize(l->start + consumed, |
254 l->len - consumed - 1); |
262 l->len - consumed - 1); |
255 if (!path || !hash || !flags) { |
263 if (!flags) { |
256 goto done; |
264 goto done; |
257 } |
265 } |
258 ret = PyTuple_Pack(3, path, hash, flags); |
266 ret = PyTuple_Pack(3, path, hash, flags); |
259 done: |
267 done: |
260 Py_XDECREF(path); |
268 Py_XDECREF(path); |