To: vim_dev@googlegroups.com Subject: Patch 8.2.2848 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2848 Problem: Crash when calling partial. Solution: Check for NULL pointer. (Dominique Pellé, closes #8202) Files: src/eval.c, src/evalfunc.c, src/testdir/test_functions.vim, src/testdir/test_listdict.vim *** ../vim-8.2.2847/src/eval.c 2021-05-09 23:19:17.089003124 +0200 --- src/eval.c 2021-05-13 14:51:56.109285816 +0200 *************** *** 4284,4293 **** char_u * partial_name(partial_T *pt) { ! if (pt->pt_name != NULL) ! return pt->pt_name; ! if (pt->pt_func != NULL) ! return pt->pt_func->uf_name; return (char_u *)""; } --- 4284,4296 ---- char_u * partial_name(partial_T *pt) { ! if (pt != NULL) ! { ! if (pt->pt_name != NULL) ! return pt->pt_name; ! if (pt->pt_func != NULL) ! return pt->pt_func->uf_name; ! } return (char_u *)""; } *** ../vim-8.2.2847/src/evalfunc.c 2021-05-09 23:19:17.089003124 +0200 --- src/evalfunc.c 2021-05-13 14:51:56.109285816 +0200 *************** *** 1971,1977 **** } /* ! * Check the argument types for builting function "idx". * Uses the list of types on the type stack: "types". * Return FAIL and gives an error message when a type is wrong. */ --- 1971,1977 ---- } /* ! * Check the argument types for builtin function "idx". * Uses the list of types on the type stack: "types". * Return FAIL and gives an error message when a type is wrong. */ *************** *** 2475,2482 **** } else func = tv_get_string(&argvars[0]); ! if (*func == NUL) ! return; // type error or empty name if (argvars[2].v_type != VAR_UNKNOWN) { --- 2475,2482 ---- } else func = tv_get_string(&argvars[0]); ! if (func == NULL || *func == NUL) ! return; // type error, empty name or null function if (argvars[2].v_type != VAR_UNKNOWN) { *************** *** 2779,2785 **** /* * Set the cursor position. ! * If 'charcol' is TRUE, then use the column number as a character offet. * Otherwise use the column number as a byte offset. */ static void --- 2779,2785 ---- /* * Set the cursor position. ! * If 'charcol' is TRUE, then use the column number as a character offset. * Otherwise use the column number as a byte offset. */ static void *** ../vim-8.2.2847/src/testdir/test_functions.vim 2021-05-06 17:36:50.988003911 +0200 --- src/testdir/test_functions.vim 2021-05-13 14:51:56.113285800 +0200 *************** *** 2150,2155 **** --- 2150,2159 ---- eval mydict.len->call([], mydict)->assert_equal(4) call assert_fails("call call('Mylen', [], 0)", 'E715:') call assert_fails('call foo', 'E107:') + + " This once caused a crash. + call call(test_null_function(), []) + call call(test_null_partial(), []) endfunc func Test_char2nr() *** ../vim-8.2.2847/src/testdir/test_listdict.vim 2021-04-08 20:09:49.267143853 +0200 --- src/testdir/test_listdict.vim 2021-05-13 14:51:56.113285800 +0200 *************** *** 743,748 **** --- 743,749 ---- " should not crash call assert_fails('echo reduce([1], test_null_function())', 'E1132:') + call assert_fails('echo reduce([1], test_null_partial())', 'E1132:') endfunc " splitting a string to a List using split() *** ../vim-8.2.2847/src/version.c 2021-05-10 23:49:34.776059886 +0200 --- src/version.c 2021-05-13 14:53:27.416927209 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2848, /**/ -- ARTHUR: This new learning amazes me, Sir Bedevere. Explain again how sheep's bladders may be employed to prevent earthquakes. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///