summaryrefslogtreecommitdiff
path: root/src/if_py_both.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-07 20:12:54 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-07 20:12:54 +0200
commitbb790dcc46b74e6f9a1c4126be8a575f9fe73444 (patch)
treec17157a26c3b5b3bbfc87fa88067ee06aec7cf08 /src/if_py_both.h
parent007f9d6ed597bd212acb95be9d0767c97d2a1438 (diff)
downloadvim-git-bb790dcc46b74e6f9a1c4126be8a575f9fe73444.tar.gz
patch 8.2.1150: ml_get error when using Pythonv8.2.1150
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".
Diffstat (limited to 'src/if_py_both.h')
-rw-r--r--src/if_py_both.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h
index c7df93be2..5bd6a0e67 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -3374,7 +3374,7 @@ OptionsItem(OptionsObject *self, PyObject *keyObject)
char_u *stringval;
PyObject *todecref;
- if (self->Check(self->from))
+ if (self->Check(self->fromObj))
return NULL;
if (!(key = StringToChars(keyObject, &todecref)))
@@ -3565,7 +3565,7 @@ OptionsAssItem(OptionsObject *self, PyObject *keyObject, PyObject *valObject)
int ret = 0;
PyObject *todecref;
- if (self->Check(self->from))
+ if (self->Check(self->fromObj))
return -1;
if (!(key = StringToChars(keyObject, &todecref)))
@@ -4334,10 +4334,15 @@ GetBufferLineList(buf_T *buf, PyInt lo, PyInt hi)
for (i = 0; i < n; ++i)
{
- PyObject *string = LineToString(
- (char *)ml_get_buf(buf, (linenr_T)(lo+i), FALSE));
+ linenr_T lnum = (linenr_T)(lo + i);
+ 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)
{
Py_DECREF(list);