Patch 8.2.2181

3 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 21, 2020, 12:24:35 PM12/21/20
to vim...@googlegroups.com

Patch 8.2.2181
Problem: Valgrind warnings for using uninitialized value.
Solution: Do not use "start" or "end" unless there is a match.
Files: src/regexp_nfa.c, src/regexp_bt.c


*** ../vim-8.2.2180/src/regexp_nfa.c 2020-12-21 14:54:28.844116987 +0100
--- src/regexp_nfa.c 2020-12-21 16:19:52.401950488 +0100
***************
*** 7227,7247 ****
#endif

theend:
! // 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 (retval > 0)
! {
! if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
! rex.reg_match->endp[0] = rex.reg_match->startp[0];
}

return retval;
--- 7227,7250 ----
#endif

theend:
! if (retval > 0)
{
! // 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;
*** ../vim-8.2.2180/src/regexp_bt.c 2020-12-09 16:36:00.400656191 +0100
--- src/regexp_bt.c 2020-12-21 16:21:43.861564338 +0100
***************
*** 4805,4825 ****
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;
--- 4805,4828 ----
if (backpos.ga_maxlen > BACKPOS_INITIAL)
ga_clear(&backpos);

! if (retval > 0)
{
! // 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;
*** ../vim-8.2.2180/src/version.c 2020-12-21 18:11:20.841680915 +0100
--- src/version.c 2020-12-21 18:23:43.499329882 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2181,
/**/

--
Imagine a world without hypothetical situations.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages