summaryrefslogtreecommitdiff
path: root/src/regexp_nfa.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-17 18:22:56 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-17 18:22:56 +0000
commit64066b9acd9f8cffdf4840f797748f938a13f2d6 (patch)
tree90b2970896cda7facf1524299581322a26e044d0 /src/regexp_nfa.c
parent615ddd5342b50a6878a907062aa471740bd9a847 (diff)
downloadvim-git-64066b9acd9f8cffdf4840f797748f938a13f2d6.tar.gz
patch 8.2.3612: using freed memory with regexp using a markv8.2.3612
Problem: Using freed memory with regexp using a mark. Solution: Get the line again after getting the mark position.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r--src/regexp_nfa.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index c7db98187..a0f1a960b 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -6834,8 +6834,16 @@ nfa_regmatch(
case NFA_MARK_GT:
case NFA_MARK_LT:
{
+ size_t col = rex.input - rex.line;
pos_T *pos = getmark_buf(rex.reg_buf, t->state->val, FALSE);
+ // Line may have been freed, get it again.
+ if (REG_MULTI)
+ {
+ rex.line = reg_getline(rex.lnum);
+ rex.input = rex.line + col;
+ }
+
// Compare the mark position to the match position, if the mark
// exists and mark is set in reg_buf.
if (pos != NULL && pos->lnum > 0)