diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-09 16:36:04 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-09 16:36:04 +0100 |
commit | a7a691cc142439e266f4ceb1f208bb952b57aa71 (patch) | |
tree | ebe600566e203253e7f6f2502c3032c2608c32ec /src/regexp_bt.c | |
parent | 730677a0dafe6f2e72888ef59f74f66f2d0a573e (diff) | |
download | vim-git-a7a691cc142439e266f4ceb1f208bb952b57aa71.tar.gz |
patch 8.2.2121: internal error when using \ze before \zs in a patternv8.2.2121
Problem: Internal error when using \ze before \zs in a pattern.
Solution: Check the end is never before the start. (closes #7442)
Diffstat (limited to 'src/regexp_bt.c')
-rw-r--r-- | src/regexp_bt.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/regexp_bt.c b/src/regexp_bt.c index 03b07a167..476f34ef4 100644 --- a/src/regexp_bt.c +++ b/src/regexp_bt.c @@ -4805,6 +4805,23 @@ theend: if (backpos.ga_maxlen > BACKPOS_INITIAL) ga_clear(&backpos); + // Make sure the end is never before the start. Can happen when \zs and + // \ze are used. + if (REG_MULTI) + { + lpos_T *start = &rex.reg_mmatch->startpos[0]; + lpos_T *end = &rex.reg_mmatch->endpos[0]; + + if (end->lnum < start->lnum + || (end->lnum == start->lnum && end->col < start->col)) + rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; + } + else + { + if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) + rex.reg_match->endp[0] = rex.reg_match->startp[0]; + } + return retval; } |