forked from aniani/vim
patch 8.2.1150: ml_get error when using Python
Problem: ml_get error when using Python. (Yegappan Lakshmanan) Solution: Check the line number is not out of range. Call "Check" with "fromObj" instead of "from".
This commit is contained in:
@@ -3374,7 +3374,7 @@ OptionsItem(OptionsObject *self, PyObject *keyObject)
|
|||||||
char_u *stringval;
|
char_u *stringval;
|
||||||
PyObject *todecref;
|
PyObject *todecref;
|
||||||
|
|
||||||
if (self->Check(self->from))
|
if (self->Check(self->fromObj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(key = StringToChars(keyObject, &todecref)))
|
if (!(key = StringToChars(keyObject, &todecref)))
|
||||||
@@ -3565,7 +3565,7 @@ OptionsAssItem(OptionsObject *self, PyObject *keyObject, PyObject *valObject)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
PyObject *todecref;
|
PyObject *todecref;
|
||||||
|
|
||||||
if (self->Check(self->from))
|
if (self->Check(self->fromObj))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(key = StringToChars(keyObject, &todecref)))
|
if (!(key = StringToChars(keyObject, &todecref)))
|
||||||
@@ -4334,10 +4334,15 @@ GetBufferLineList(buf_T *buf, PyInt lo, PyInt hi)
|
|||||||
|
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
PyObject *string = LineToString(
|
linenr_T lnum = (linenr_T)(lo + i);
|
||||||
(char *)ml_get_buf(buf, (linenr_T)(lo+i), FALSE));
|
char *text;
|
||||||
|
PyObject *string;
|
||||||
|
|
||||||
// Error check - was the Python string creation OK?
|
if (lnum > buf->b_ml.ml_line_count)
|
||||||
|
text = "";
|
||||||
|
else
|
||||||
|
text = (char *)ml_get_buf(buf, lnum, FALSE);
|
||||||
|
string = LineToString(text);
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
{
|
{
|
||||||
Py_DECREF(list);
|
Py_DECREF(list);
|
||||||
|
@@ -278,9 +278,9 @@ func Test_python_range()
|
|||||||
py r[1:0] = ["d"]
|
py r[1:0] = ["d"]
|
||||||
call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
|
call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
|
||||||
|
|
||||||
" FIXME: The following code triggers ml_get errors
|
" The following code used to trigger an ml_get error
|
||||||
" %d
|
%d
|
||||||
" let x = pyeval('r[:]')
|
let x = pyeval('r[:]')
|
||||||
|
|
||||||
" Non-existing range attribute
|
" Non-existing range attribute
|
||||||
call AssertException(["let x = pyeval('r.abc')"],
|
call AssertException(["let x = pyeval('r.abc')"],
|
||||||
@@ -332,9 +332,9 @@ func Test_python_window()
|
|||||||
call AssertException(["py vim.current.window = w"],
|
call AssertException(["py vim.current.window = w"],
|
||||||
\ 'Vim(python):vim.error: attempt to refer to deleted window')
|
\ 'Vim(python):vim.error: attempt to refer to deleted window')
|
||||||
" Try to set one of the options of the closed window
|
" Try to set one of the options of the closed window
|
||||||
" FIXME: The following causes ASAN failure
|
" The following caused an ASAN failure
|
||||||
"call AssertException(["py wopts['list'] = False"],
|
call AssertException(["py wopts['list'] = False"],
|
||||||
" \ 'vim.error: problem while switching windows')
|
\ 'vim.error: attempt to refer to deleted window')
|
||||||
call assert_match('<window object (deleted)', pyeval("repr(w)"))
|
call assert_match('<window object (deleted)', pyeval("repr(w)"))
|
||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -462,9 +462,9 @@ func Test_python3_range2()
|
|||||||
py3 r[1:0] = ["d"]
|
py3 r[1:0] = ["d"]
|
||||||
call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
|
call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
|
||||||
|
|
||||||
" FIXME: The following code triggers ml_get errors
|
" The following code used to trigger an ml_get error
|
||||||
" %d
|
%d
|
||||||
" let x = py3eval('r[:]')
|
let x = py3eval('r[:]')
|
||||||
|
|
||||||
" Non-existing range attribute
|
" Non-existing range attribute
|
||||||
call AssertException(["let x = py3eval('r.abc')"],
|
call AssertException(["let x = py3eval('r.abc')"],
|
||||||
@@ -516,9 +516,9 @@ func Test_python3_window()
|
|||||||
call AssertException(["py3 vim.current.window = w"],
|
call AssertException(["py3 vim.current.window = w"],
|
||||||
\ 'Vim(py3):vim.error: attempt to refer to deleted window')
|
\ 'Vim(py3):vim.error: attempt to refer to deleted window')
|
||||||
" Try to set one of the options of the closed window
|
" Try to set one of the options of the closed window
|
||||||
" FIXME: The following causes ASAN failure
|
" The following caused ASAN failure
|
||||||
"call AssertException(["py3 wopts['list'] = False"],
|
call AssertException(["py3 wopts['list'] = False"],
|
||||||
" \ 'Vim(py3):vim.error: problem while switching windows')
|
\ 'Vim(py3):vim.error: attempt to refer to deleted window')
|
||||||
call assert_match('<window object (deleted)', py3eval("repr(w)"))
|
call assert_match('<window object (deleted)', py3eval("repr(w)"))
|
||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1150,
|
||||||
/**/
|
/**/
|
||||||
1149,
|
1149,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user