From d8cd15e8d67d76a327b5ffa75d54a23dc05b58c9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 21 Sep 2024 18:26:44 +0800 Subject: vim-patch:9.1.0739: [security]: use-after-free in ex_getln.c (#30448) Problem: [security]: use-after-free in ex_getln.c Solution: free pointer p a bit later (John Marriott) closes: vim/vim#15712 https://github.com/vim/vim/commit/a6de28755ec3fcc86d1ed0b744f1b410a8e9702d Co-authored-by: John Marriott --- src/nvim/ex_getln.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 722a857f03..6a57b3ab78 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3028,7 +3028,6 @@ void realloc_cmdbuff(int len) // there, thus copy up to the NUL and add a NUL. memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen); ccline.cmdbuff[ccline.cmdlen] = NUL; - xfree(p); if (ccline.xpc != NULL && ccline.xpc->xp_pattern != NULL @@ -3042,6 +3041,8 @@ void realloc_cmdbuff(int len) ccline.xpc->xp_pattern = ccline.cmdbuff + i; } } + + xfree(p); } enum { MAX_CB_ERRORS = 1, }; -- cgit