#ifdef FEAT_EVAL
if (name == MB_TOLOWER(redir_reg)
- || (redir_reg == '"' && yb == y_previous))
+ || (vim_strchr((char_u *)"\"*+", redir_reg) != NULL &&
+ (yb == y_previous || yb == &y_regs[0])))
continue; // do not list register being written to, the
// pointer can be freed
#endif
let $DISPLAY=display
endfunc
+" This caused use-after-free
+func Test_register_redir_display()
+ " don't touch the clipboard, so only perform this, when the clipboard is not working
+ if has("clipboard_working")
+ throw "Skipped: skip touching the clipboard register!"
+ endif
+ let @"=''
+ redir @+>
+ disp +"
+ redir END
+ call assert_equal("\nType Name Content", getreg('+'))
+ let a = [getreg('1'), getregtype('1')]
+ let @1='register 1'
+ redir @+
+ disp 1
+ redir END
+ call assert_equal("register 1", getreg('1'))
+ call setreg(1, a[0], a[1])
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab