if (copy)
{
// If we run out of memory some or all of the lines are empty.
- if (reg->y_size == 0)
+ 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);
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\80PS\ 3\11P
+ 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()