To: vim_dev@googlegroups.com Subject: Patch 9.0.1531 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1531 Problem: Crash when register contents ends up being invalid. Solution: Check "y_array" is not NULL. Files: src/register.c, src/testdir/test_registers.vim *** ../vim-9.0.1530/src/register.c 2023-03-04 14:13:07.334568146 +0000 --- src/register.c 2023-05-09 17:08:00.829585276 +0100 *************** *** 301,307 **** if (copy) { // If we run out of memory some or all of the lines are empty. ! if (reg->y_size == 0) reg->y_array = NULL; else reg->y_array = ALLOC_MULT(char_u *, reg->y_size); --- 301,307 ---- if (copy) { // If we run out of memory some or all of the lines are empty. ! if (reg->y_size == 0 || y_current->y_array == NULL) reg->y_array = NULL; else reg->y_array = ALLOC_MULT(char_u *, reg->y_size); *** ../vim-9.0.1530/src/testdir/test_registers.vim 2022-11-24 11:31:26.029276217 +0000 --- src/testdir/test_registers.vim 2023-05-09 17:05:32.149768816 +0100 *************** *** 835,840 **** --- 835,857 ---- bwipe! endfunc + " This was causing a crash because y_append was ending up being NULL + func Test_zero_y_append() + " Run in a separate Vim instance because changing 'encoding' may cause + " trouble for later tests. + let lines =<< trim END + d + silent ?n + next + so + sil! norm 0V€PSP + set enc=latin1 +   + END + call writefile(lines, 'XTest_zero_y_append', 'D') + call RunVim([], [], '-u NONE -i NONE -e -s -S XTest_zero_y_append -c qa\!') + endfunc + " Make sure that y_append is correctly reset " and the previous register is working as expected func Test_register_y_append_reset() *** ../vim-9.0.1530/src/version.c 2023-05-09 16:00:59.958881540 +0100 --- src/version.c 2023-05-09 16:52:15.335621815 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1531, /**/ -- Bypasses are devices that allow some people to dash from point A to point B very fast while other people dash from point B to point A very fast. People living at point C, being a point directly in between, are often given to wonder what's so great about point A that so many people from point B are so keen to get there and what's so great about point B that so many people from point A are so keen to get there. They often wish that people would just once and for all work out where the hell they wanted to be. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// 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 ///