mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
updated for version 7.3.942
Problem: Python: SEGV in Buffer functions. Solution: Call CheckBuffer() at the right time. (ZyX)
This commit is contained in:
@@ -2391,6 +2391,9 @@ RBItem(BufferObject *self, PyInt n, PyInt start, PyInt end)
|
|||||||
if (CheckBuffer(self))
|
if (CheckBuffer(self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (end == -1)
|
||||||
|
end = self->buf->b_ml.ml_line_count;
|
||||||
|
|
||||||
if (n < 0 || n > end - start)
|
if (n < 0 || n > end - start)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
||||||
@@ -2408,6 +2411,9 @@ RBSlice(BufferObject *self, PyInt lo, PyInt hi, PyInt start, PyInt end)
|
|||||||
if (CheckBuffer(self))
|
if (CheckBuffer(self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (end == -1)
|
||||||
|
end = self->buf->b_ml.ml_line_count;
|
||||||
|
|
||||||
size = end - start + 1;
|
size = end - start + 1;
|
||||||
|
|
||||||
if (lo < 0)
|
if (lo < 0)
|
||||||
@@ -2432,6 +2438,9 @@ RBAsItem(BufferObject *self, PyInt n, PyObject *val, PyInt start, PyInt end, PyI
|
|||||||
if (CheckBuffer(self))
|
if (CheckBuffer(self))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (end == -1)
|
||||||
|
end = self->buf->b_ml.ml_line_count;
|
||||||
|
|
||||||
if (n < 0 || n > end - start)
|
if (n < 0 || n > end - start)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
||||||
@@ -2457,6 +2466,9 @@ RBAsSlice(BufferObject *self, PyInt lo, PyInt hi, PyObject *val, PyInt start, Py
|
|||||||
if (CheckBuffer(self))
|
if (CheckBuffer(self))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (end == -1)
|
||||||
|
end = self->buf->b_ml.ml_line_count;
|
||||||
|
|
||||||
/* Sort out the slice range */
|
/* Sort out the slice range */
|
||||||
size = end - start + 1;
|
size = end - start + 1;
|
||||||
|
|
||||||
@@ -2493,6 +2505,9 @@ RBAppend(BufferObject *self, PyObject *args, PyInt start, PyInt end, PyInt *new_
|
|||||||
if (CheckBuffer(self))
|
if (CheckBuffer(self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (end == -1)
|
||||||
|
end = self->buf->b_ml.ml_line_count;
|
||||||
|
|
||||||
max = n = end - start + 1;
|
max = n = end - start + 1;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O|n", &lines, &n))
|
if (!PyArg_ParseTuple(args, "O|n", &lines, &n))
|
||||||
@@ -2700,15 +2715,13 @@ BufferLength(PyObject *self)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
BufferItem(PyObject *self, PyInt n)
|
BufferItem(PyObject *self, PyInt n)
|
||||||
{
|
{
|
||||||
return RBItem((BufferObject *)(self), n, 1,
|
return RBItem((BufferObject *)(self), n, 1, -1);
|
||||||
(PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
BufferSlice(PyObject *self, PyInt lo, PyInt hi)
|
BufferSlice(PyObject *self, PyInt lo, PyInt hi)
|
||||||
{
|
{
|
||||||
return RBSlice((BufferObject *)(self), lo, hi, 1,
|
return RBSlice((BufferObject *)(self), lo, hi, 1, -1);
|
||||||
(PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
@@ -2732,9 +2745,7 @@ BufferAttr(BufferObject *this, char *name)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
BufferAppend(PyObject *self, PyObject *args)
|
BufferAppend(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
return RBAppend((BufferObject *)(self), args, 1,
|
return RBAppend((BufferObject *)(self), args, 1, -1, NULL);
|
||||||
(PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@@ -1073,17 +1073,13 @@ BufferGetattr(PyObject *self, char *name)
|
|||||||
static PyInt
|
static PyInt
|
||||||
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
|
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
|
||||||
{
|
{
|
||||||
return RBAsItem((BufferObject *)(self), n, val, 1,
|
return RBAsItem((BufferObject *)(self), n, val, 1, -1, NULL);
|
||||||
(PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyInt
|
static PyInt
|
||||||
BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
|
BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
|
||||||
{
|
{
|
||||||
return RBAsSlice((BufferObject *)(self), lo, hi, val, 1,
|
return RBAsSlice((BufferObject *)(self), lo, hi, val, 1, -1, NULL);
|
||||||
(PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PySequenceMethods RangeAsSeq = {
|
static PySequenceMethods RangeAsSeq = {
|
||||||
|
@@ -1110,6 +1110,9 @@ BufferSubscript(PyObject *self, PyObject* idx)
|
|||||||
{
|
{
|
||||||
Py_ssize_t start, stop, step, slicelen;
|
Py_ssize_t start, stop, step, slicelen;
|
||||||
|
|
||||||
|
if (CheckBuffer((BufferObject *) self))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (PySlice_GetIndicesEx((PyObject *)idx,
|
if (PySlice_GetIndicesEx((PyObject *)idx,
|
||||||
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
||||||
&start, &stop,
|
&start, &stop,
|
||||||
@@ -1139,6 +1142,9 @@ BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
|
|||||||
{
|
{
|
||||||
Py_ssize_t start, stop, step, slicelen;
|
Py_ssize_t start, stop, step, slicelen;
|
||||||
|
|
||||||
|
if (CheckBuffer((BufferObject *) self))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (PySlice_GetIndicesEx((PyObject *)idx,
|
if (PySlice_GetIndicesEx((PyObject *)idx,
|
||||||
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
||||||
&start, &stop,
|
&start, &stop,
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
942,
|
||||||
/**/
|
/**/
|
||||||
941,
|
941,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user