diff src/edit.c @ 27380:7c07681f8a05 v8.2.4218

patch 8.2.4218: illegal memory access with bracketed paste in Ex mode Commit: https://github.com/vim/vim/commit/806d037671e133bd28a7864248763f643967973a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 25 20:45:16 2022 +0000 patch 8.2.4218: illegal memory access with bracketed paste in Ex mode Problem: Illegal memory access with bracketed paste in Ex mode. Solution: Reserve space for the trailing NUL.
author Bram Moolenaar <Bram@vim.org>
date Tue, 25 Jan 2022 22:00:04 +0100
parents 63179e8300f8
children 41e0dcf38521
line wrap: on
line diff
--- a/src/edit.c
+++ b/src/edit.c
@@ -4452,7 +4452,8 @@ bracketed_paste(paste_mode_T mode, int d
 		    break;
 
 		case PASTE_EX:
-		    if (gap != NULL && ga_grow(gap, idx) == OK)
+		    // add one for the NUL that is going to be appended
+		    if (gap != NULL && ga_grow(gap, idx + 1) == OK)
 		    {
 			mch_memmove((char *)gap->ga_data + gap->ga_len,
 							     buf, (size_t)idx);