To: vim_dev@googlegroups.com Subject: Patch 8.2.3006 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3006 Problem: Crash when echoing a value very early. (Naruhiko Nishino) Solution: Do not use a NUL to truncate the message, make a copy. (closes #8388) Files: src/message.c, src/testdir/test_startup.vim *** ../vim-8.2.3005/src/message.c 2021-04-10 14:03:40.312675756 +0200 --- src/message.c 2021-06-15 22:38:23.738140926 +0200 *************** *** 2751,2769 **** if (*p != NUL && !(silent_mode && p_verbose == 0)) { ! int c = -1; if (maxlen > 0 && STRLEN(p) > (size_t)maxlen) { ! c = p[maxlen]; ! p[maxlen] = 0; } - if (info_message) - mch_msg((char *)p); - else - mch_errmsg((char *)p); - if (c != -1) - p[maxlen] = c; } msg_didout = TRUE; // assume that line is not empty --- 2751,2771 ---- if (*p != NUL && !(silent_mode && p_verbose == 0)) { ! char_u *tofree = NULL; if (maxlen > 0 && STRLEN(p) > (size_t)maxlen) { ! tofree = vim_strnsave(p, (size_t)maxlen); ! p = tofree; ! } ! if (p != NULL) ! { ! if (info_message) ! mch_msg((char *)p); ! else ! mch_errmsg((char *)p); ! vim_free(tofree); } } msg_didout = TRUE; // assume that line is not empty *** ../vim-8.2.3005/src/testdir/test_startup.vim 2021-06-02 16:49:27.754997419 +0200 --- src/testdir/test_startup.vim 2021-06-15 22:37:57.962207170 +0200 *************** *** 1301,1304 **** --- 1301,1318 ---- call delete('Xvimrc') endfunc + func Test_echo_true_in_cmd() + let lines =<< trim END + echo v:true + call writefile(['done'], 'Xresult') + END + call writefile(lines, 'Xscript') + if RunVim([], [], '--cmd "source Xscript" --c q') + call assert_equal(['done'], readfile('Xresult')) + endif + call delete('Xscript') + call delete('Xresult') + + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3005/src/version.c 2021-06-15 22:13:23.829621578 +0200 --- src/version.c 2021-06-15 22:26:11.299968415 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 3006, /**/ -- The fastest way to get an engineer to solve a problem is to declare that the problem is unsolvable. No engineer can walk away from an unsolvable problem until it's solved. (Scott Adams - The Dilbert principle) /// 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 ///