From 35a3423c6ae785bf739319e1ec416b2de1462a8c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 13 Aug 2010 16:51:26 +0200 Subject: Fix illegal memory access when using expressions in the command line. --- src/ex_getln.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ex_getln.c') diff --git a/src/ex_getln.c b/src/ex_getln.c index d2925535e..1cf678543 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -2527,7 +2527,10 @@ realloc_cmdbuff(len) ccline.cmdbuff = p; /* keep the old one */ return FAIL; } - mch_memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen + 1); + /* There isn't always a NUL after the command, but it may need to be + * there, thus copy up to the NUL and add a NUL. */ + mch_memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen); + ccline.cmdbuff[ccline.cmdlen] = NUL; vim_free(p); if (ccline.xpc != NULL -- cgit v1.2.1