aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-03-24 14:03:16 +0100
committerGitHub <noreply@github.com>2018-03-24 14:03:16 +0100
commit84a25770ac4b1c18f0e6bd1e17bdda7eb3c6afa0 (patch)
tree870b2448151069c8ebb825911f032d6c8a1cb4d3 /src/nvim/ex_docmd.c
parent96273256843ea357d62696ef307d6610ba97334c (diff)
parent82cd0be2eaf71c0476e15c66ba3e83c76896d407 (diff)
downloadrneovim-84a25770ac4b1c18f0e6bd1e17bdda7eb3c6afa0.tar.gz
rneovim-84a25770ac4b1c18f0e6bd1e17bdda7eb3c6afa0.tar.bz2
rneovim-84a25770ac4b1c18f0e6bd1e17bdda7eb3c6afa0.zip
Merge #8165 'provider/RPC: fix double-free'
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index e1d28b4a9c..a0966dc1fc 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -8546,16 +8546,16 @@ eval_vars (
resultbuf = result; /* remember allocated string */
break;
- case SPEC_AFILE: /* file name for autocommand */
- result = autocmd_fname;
- if (result != NULL && !autocmd_fname_full) {
- /* Still need to turn the fname into a full path. It is
- * postponed to avoid a delay when <afile> is not used. */
- autocmd_fname_full = TRUE;
- result = (char_u *)FullName_save((char *)autocmd_fname, FALSE);
- xfree(autocmd_fname);
- autocmd_fname = result;
+ case SPEC_AFILE: // file name for autocommand
+ if (autocmd_fname != NULL && !path_is_absolute_path(autocmd_fname)) {
+ // Still need to turn the fname into a full path. It was
+ // postponed to avoid a delay when <afile> is not used.
+ result = (char_u *)FullName_save((char *)autocmd_fname, false);
+ // Copy into `autocmd_fname`, don't reassign it. #8165
+ xstrlcpy((char *)autocmd_fname, (char *)result, MAXPATHL);
+ xfree(result);
}
+ result = autocmd_fname;
if (result == NULL) {
*errormsg = (char_u *)_(
"E495: no autocommand file name to substitute for \"<afile>\"");