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 <sfile>
+       so
+       sil! norm 0V€PS  P
+       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 -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230509161006.A1E021C1B27%40moolenaar.net.

Raspunde prin e-mail lui