|
Karsten Hopp |
abbeab |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
abbeab |
Subject: Patch 7.3.942
|
|
Karsten Hopp |
abbeab |
Fcc: outbox
|
|
Karsten Hopp |
abbeab |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
abbeab |
Mime-Version: 1.0
|
|
Karsten Hopp |
abbeab |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
abbeab |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
abbeab |
------------
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
Patch 7.3.942
|
|
Karsten Hopp |
abbeab |
Problem: Python: SEGV in Buffer functions.
|
|
Karsten Hopp |
abbeab |
Solution: Call CheckBuffer() at the right time. (ZyX)
|
|
Karsten Hopp |
abbeab |
Files: src/if_py_both.h, src/if_python.c, src/if_python3.c
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
*** ../vim-7.3.941/src/if_py_both.h 2013-05-12 19:45:30.000000000 +0200
|
|
Karsten Hopp |
abbeab |
--- src/if_py_both.h 2013-05-12 20:19:08.000000000 +0200
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 2391,2396 ****
|
|
Karsten Hopp |
abbeab |
--- 2391,2399 ----
|
|
Karsten Hopp |
abbeab |
if (CheckBuffer(self))
|
|
Karsten Hopp |
abbeab |
return NULL;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
+ if (end == -1)
|
|
Karsten Hopp |
abbeab |
+ end = self->buf->b_ml.ml_line_count;
|
|
Karsten Hopp |
abbeab |
+
|
|
Karsten Hopp |
abbeab |
if (n < 0 || n > end - start)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 2408,2413 ****
|
|
Karsten Hopp |
abbeab |
--- 2411,2419 ----
|
|
Karsten Hopp |
abbeab |
if (CheckBuffer(self))
|
|
Karsten Hopp |
abbeab |
return NULL;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
+ if (end == -1)
|
|
Karsten Hopp |
abbeab |
+ end = self->buf->b_ml.ml_line_count;
|
|
Karsten Hopp |
abbeab |
+
|
|
Karsten Hopp |
abbeab |
size = end - start + 1;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
if (lo < 0)
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 2432,2437 ****
|
|
Karsten Hopp |
abbeab |
--- 2438,2446 ----
|
|
Karsten Hopp |
abbeab |
if (CheckBuffer(self))
|
|
Karsten Hopp |
abbeab |
return -1;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
+ if (end == -1)
|
|
Karsten Hopp |
abbeab |
+ end = self->buf->b_ml.ml_line_count;
|
|
Karsten Hopp |
abbeab |
+
|
|
Karsten Hopp |
abbeab |
if (n < 0 || n > end - start)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 2457,2462 ****
|
|
Karsten Hopp |
abbeab |
--- 2466,2474 ----
|
|
Karsten Hopp |
abbeab |
if (CheckBuffer(self))
|
|
Karsten Hopp |
abbeab |
return -1;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
+ if (end == -1)
|
|
Karsten Hopp |
abbeab |
+ end = self->buf->b_ml.ml_line_count;
|
|
Karsten Hopp |
abbeab |
+
|
|
Karsten Hopp |
abbeab |
/* Sort out the slice range */
|
|
Karsten Hopp |
abbeab |
size = end - start + 1;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 2493,2498 ****
|
|
Karsten Hopp |
abbeab |
--- 2505,2513 ----
|
|
Karsten Hopp |
abbeab |
if (CheckBuffer(self))
|
|
Karsten Hopp |
abbeab |
return NULL;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
+ if (end == -1)
|
|
Karsten Hopp |
abbeab |
+ end = self->buf->b_ml.ml_line_count;
|
|
Karsten Hopp |
abbeab |
+
|
|
Karsten Hopp |
abbeab |
max = n = end - start + 1;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
if (!PyArg_ParseTuple(args, "O|n", &lines, &n))
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 2700,2714 ****
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
BufferItem(PyObject *self, PyInt n)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBItem((BufferObject *)(self), n, 1,
|
|
Karsten Hopp |
abbeab |
! (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
BufferSlice(PyObject *self, PyInt lo, PyInt hi)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBSlice((BufferObject *)(self), lo, hi, 1,
|
|
Karsten Hopp |
abbeab |
! (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
--- 2715,2727 ----
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
BufferItem(PyObject *self, PyInt n)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBItem((BufferObject *)(self), n, 1, -1);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
BufferSlice(PyObject *self, PyInt lo, PyInt hi)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBSlice((BufferObject *)(self), lo, hi, 1, -1);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 2732,2740 ****
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
BufferAppend(PyObject *self, PyObject *args)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBAppend((BufferObject *)(self), args, 1,
|
|
Karsten Hopp |
abbeab |
! (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
Karsten Hopp |
abbeab |
! NULL);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
--- 2745,2751 ----
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
BufferAppend(PyObject *self, PyObject *args)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBAppend((BufferObject *)(self), args, 1, -1, NULL);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyObject *
|
|
Karsten Hopp |
abbeab |
*** ../vim-7.3.941/src/if_python.c 2013-05-12 19:45:30.000000000 +0200
|
|
Karsten Hopp |
abbeab |
--- src/if_python.c 2013-05-12 20:19:08.000000000 +0200
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 1073,1089 ****
|
|
Karsten Hopp |
abbeab |
static PyInt
|
|
Karsten Hopp |
abbeab |
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBAsItem((BufferObject *)(self), n, val, 1,
|
|
Karsten Hopp |
abbeab |
! (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
Karsten Hopp |
abbeab |
! NULL);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyInt
|
|
Karsten Hopp |
abbeab |
BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBAsSlice((BufferObject *)(self), lo, hi, val, 1,
|
|
Karsten Hopp |
abbeab |
! (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
Karsten Hopp |
abbeab |
! NULL);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PySequenceMethods RangeAsSeq = {
|
|
Karsten Hopp |
abbeab |
--- 1073,1085 ----
|
|
Karsten Hopp |
abbeab |
static PyInt
|
|
Karsten Hopp |
abbeab |
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBAsItem((BufferObject *)(self), n, val, 1, -1, NULL);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PyInt
|
|
Karsten Hopp |
abbeab |
BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
! return RBAsSlice((BufferObject *)(self), lo, hi, val, 1, -1, NULL);
|
|
Karsten Hopp |
abbeab |
}
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
static PySequenceMethods RangeAsSeq = {
|
|
Karsten Hopp |
abbeab |
*** ../vim-7.3.941/src/if_python3.c 2013-05-12 18:44:44.000000000 +0200
|
|
Karsten Hopp |
abbeab |
--- src/if_python3.c 2013-05-12 20:19:08.000000000 +0200
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 1110,1115 ****
|
|
Karsten Hopp |
abbeab |
--- 1110,1118 ----
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
Py_ssize_t start, stop, step, slicelen;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
+ if (CheckBuffer((BufferObject *) self))
|
|
Karsten Hopp |
abbeab |
+ return NULL;
|
|
Karsten Hopp |
abbeab |
+
|
|
Karsten Hopp |
abbeab |
if (PySlice_GetIndicesEx((PyObject *)idx,
|
|
Karsten Hopp |
abbeab |
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
|
Karsten Hopp |
abbeab |
&start, &stop,
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 1139,1144 ****
|
|
Karsten Hopp |
abbeab |
--- 1142,1150 ----
|
|
Karsten Hopp |
abbeab |
{
|
|
Karsten Hopp |
abbeab |
Py_ssize_t start, stop, step, slicelen;
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
+ if (CheckBuffer((BufferObject *) self))
|
|
Karsten Hopp |
abbeab |
+ return -1;
|
|
Karsten Hopp |
abbeab |
+
|
|
Karsten Hopp |
abbeab |
if (PySlice_GetIndicesEx((PyObject *)idx,
|
|
Karsten Hopp |
abbeab |
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
|
Karsten Hopp |
abbeab |
&start, &stop,
|
|
Karsten Hopp |
abbeab |
*** ../vim-7.3.941/src/version.c 2013-05-12 19:45:30.000000000 +0200
|
|
Karsten Hopp |
abbeab |
--- src/version.c 2013-05-12 19:49:58.000000000 +0200
|
|
Karsten Hopp |
abbeab |
***************
|
|
Karsten Hopp |
abbeab |
*** 730,731 ****
|
|
Karsten Hopp |
abbeab |
--- 730,733 ----
|
|
Karsten Hopp |
abbeab |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
abbeab |
+ /**/
|
|
Karsten Hopp |
abbeab |
+ 942,
|
|
Karsten Hopp |
abbeab |
/**/
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
--
|
|
Karsten Hopp |
abbeab |
Vim is like Emacs without all the typing. (John "Johann" Spetz)
|
|
Karsten Hopp |
abbeab |
|
|
Karsten Hopp |
abbeab |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
abbeab |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
abbeab |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
abbeab |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|