To: vim_dev@googlegroups.com Subject: Patch 8.2.1150 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.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". Files: src/if_py_both.h, src/testdir/test_python2.vim, src/testdir/test_python3.vim *** ../vim-8.2.1149/src/if_py_both.h 2020-07-06 21:03:02.589331536 +0200 --- src/if_py_both.h 2020-07-07 20:02:04.662755855 +0200 *************** *** 3374,3380 **** char_u *stringval; PyObject *todecref; ! if (self->Check(self->from)) return NULL; if (!(key = StringToChars(keyObject, &todecref))) --- 3374,3380 ---- char_u *stringval; PyObject *todecref; ! if (self->Check(self->fromObj)) return NULL; if (!(key = StringToChars(keyObject, &todecref))) *************** *** 3565,3571 **** int ret = 0; PyObject *todecref; ! if (self->Check(self->from)) return -1; if (!(key = StringToChars(keyObject, &todecref))) --- 3565,3571 ---- int ret = 0; PyObject *todecref; ! if (self->Check(self->fromObj)) return -1; if (!(key = StringToChars(keyObject, &todecref))) *************** *** 4334,4343 **** for (i = 0; i < n; ++i) { ! PyObject *string = LineToString( ! (char *)ml_get_buf(buf, (linenr_T)(lo+i), FALSE)); ! // Error check - was the Python string creation OK? if (string == NULL) { Py_DECREF(list); --- 4334,4348 ---- for (i = 0; i < n; ++i) { ! linenr_T lnum = (linenr_T)(lo + i); ! char *text; ! PyObject *string; ! 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); *** ../vim-8.2.1149/src/testdir/test_python2.vim 2020-07-06 21:03:02.589331536 +0200 --- src/testdir/test_python2.vim 2020-07-07 20:10:14.525188346 +0200 *************** *** 278,286 **** py r[1:0] = ["d"] call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$')) ! " FIXME: The following code triggers ml_get errors ! " %d ! " let x = pyeval('r[:]') " Non-existing range attribute call AssertException(["let x = pyeval('r.abc')"], --- 278,286 ---- py r[1:0] = ["d"] call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$')) ! " The following code used to trigger an ml_get error ! %d ! let x = pyeval('r[:]') " Non-existing range attribute call AssertException(["let x = pyeval('r.abc')"], *************** *** 332,340 **** call AssertException(["py vim.current.window = w"], \ 'Vim(python):vim.error: attempt to refer to deleted window') " Try to set one of the options of the closed window ! " FIXME: The following causes ASAN failure ! "call AssertException(["py wopts['list'] = False"], ! " \ 'vim.error: problem while switching windows') call assert_match('