diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-05 12:06:24 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-05 12:06:24 +0000 |
commit | e031fe90cf2e375ce861ff5e5e281e4ad229ebb9 (patch) | |
tree | 8723b11cb324f35a8959b759ad94c106e3f62dad /src/ex_docmd.c | |
parent | c7269f862748c3b0f56b5a651019e18c7d5190ee (diff) |
patch 8.2.3741: using freed memory in open commandv8.2.3741
Problem: Using freed memory in open command.
Solution: Make a copy of the current line.
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 439a78cedc..1fc538b85c 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -6877,13 +6877,17 @@ ex_open(exarg_T *eap) regmatch.regprog = vim_regcomp(eap->arg, magic_isset() ? RE_MAGIC : 0); if (regmatch.regprog != NULL) { + // make a copy of the line, when searching for a mark it might be + // flushed + char_u *line = vim_strsave(ml_get_curline()); + regmatch.rm_ic = p_ic; - p = ml_get_curline(); - if (vim_regexec(®match, p, (colnr_T)0)) - curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); + if (vim_regexec(®match, line, (colnr_T)0)) + curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - line); else emsg(_(e_nomatch)); vim_regfree(regmatch.regprog); + vim_free(line); } // Move to the NUL, ignore any other arguments. eap->arg += STRLEN(eap->arg); |