Mercurial > hg
comparison mercurial/parsers.c @ 26872:ce03e72837c6 stable
parsers: fix width of datalen variable in fm1readmarkers
Because parsers.c does not define PY_SSIZE_T_CLEAN, "s#" format requires
(const char*, int), not (const char*, Py_ssize_t).
https://docs.python.org/2/c-api/arg.html
This error had no problem before 042344313939, where datalen wasn't used.
But now fm1readmarkers() fails with "overflow in obsstore" on Python 2.6.9
(amd64) because upper bits of datalen seem to be filled with 1, making it
a negative integer.
This problem seems not visible on our Python 2.7 environment because upper
bits happen to be filled with 0.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 07 Nov 2015 17:43:20 +0900 |
parents | 3c259710737c |
children | f5e8cb813a4d |
comparison
equal
deleted
inserted
replaced
26861:10a1a4b3e775 | 26872:ce03e72837c6 |
---|---|
2690 } | 2690 } |
2691 | 2691 |
2692 | 2692 |
2693 static PyObject *fm1readmarkers(PyObject *self, PyObject *args) { | 2693 static PyObject *fm1readmarkers(PyObject *self, PyObject *args) { |
2694 const char *data, *dataend; | 2694 const char *data, *dataend; |
2695 Py_ssize_t datalen; | 2695 int datalen; |
2696 Py_ssize_t offset, stop; | 2696 Py_ssize_t offset, stop; |
2697 PyObject *markers = NULL; | 2697 PyObject *markers = NULL; |
2698 | 2698 |
2699 if (!PyArg_ParseTuple(args, "s#nn", &data, &datalen, &offset, &stop)) { | 2699 if (!PyArg_ParseTuple(args, "s#nn", &data, &datalen, &offset, &stop)) { |
2700 return NULL; | 2700 return NULL; |