From f7f65f5a82346a18c3ddf7143d64e8ce3ad399e2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 10 Aug 2018 09:42:07 -0400 Subject: vim-patch:8.0.1254: undefined left shift in gethexchrs() Problem: Undefined left shift in gethexchrs(). (geeknik) Solution: Use unsigned long. (idea by Christian Brabandt, closes vim/vim#2255) https://github.com/vim/vim/commit/4c22a91d20cce4f28dd2852a13129b5a4cc691da --- src/nvim/regexp.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index be6c43493b..9bfc158763 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1664,9 +1664,8 @@ static char_u *regpiece(int *flagp) case Magic('@'): { int lop = END; - int nr; + int64_t nr = getdecchrs(); - nr = getdecchrs(); switch (no_Magic(getchr())) { case '=': lop = MATCH; break; /* \@= */ case '!': lop = NOMATCH; break; /* \@! */ @@ -2087,7 +2086,7 @@ static char_u *regatom(int *flagp) case 'u': /* %uabcd hex 4 */ case 'U': /* %U1234abcd hex 8 */ { - int i; + int64_t i; switch (c) { case 'd': i = getdecchrs(); break; @@ -2976,9 +2975,9 @@ static void ungetchr(void) * The parameter controls the maximum number of input characters. This will be * 2 when reading a \%x20 sequence and 4 when reading a \%u20AC sequence. */ -static int gethexchrs(int maxinputlen) +static int64_t gethexchrs(int maxinputlen) { - int nr = 0; + int64_t nr = 0; int c; int i; @@ -3000,9 +2999,9 @@ static int gethexchrs(int maxinputlen) * Get and return the value of the decimal string immediately after the * current position. Return -1 for invalid. Consumes all digits. */ -static int getdecchrs(void) +static int64_t getdecchrs(void) { - int nr = 0; + int64_t nr = 0; int c; int i; @@ -3029,9 +3028,9 @@ static int getdecchrs(void) * blahblah\%o210asdf * before-^ ^-after */ -static int getoctchrs(void) +static int64_t getoctchrs(void) { - int nr = 0; + int64_t nr = 0; int c; int i; @@ -3055,7 +3054,7 @@ static int getoctchrs(void) */ static int coll_get_char(void) { - int nr = -1; + int64_t nr = -1; switch (*regparse++) { case 'd': nr = getdecchrs(); break; -- cgit From cb708d203b36fff16b6f01a81c30ca20b51c82fc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 10 Aug 2018 10:41:26 -0400 Subject: vim-patch:8.0.1517: invalid memory acces with pattern using look-behind match Problem: Invalid memory acces with pattern using look-behind match. (Dominique Pelle) Solution: Get a pointer to the right line. https://github.com/vim/vim/commit/bc197195b097707d08fd44a476dbc374366504cb --- src/nvim/regexp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 9bfc158763..9d16ecb46c 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -4922,8 +4922,11 @@ regmatch ( } } else { if (has_mbyte) { + const char_u *const line = + reg_getline(behind_pos.rs_u.pos.lnum); + rp->rs_un.regsave.rs_u.pos.col -= - (*mb_head_off)(regline, regline + (*mb_head_off)(line, line + rp->rs_un.regsave.rs_u.pos.col - 1) + 1; } else { rp->rs_un.regsave.rs_u.pos.col--; -- cgit From d6a25f89b8d664fa2a42f730e78e780fb611b0b9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 11 Aug 2018 17:45:17 -0400 Subject: regexp: drop has_mbyte check in regmatch() has_mbyte is always true in nvim. --- src/nvim/regexp.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 9d16ecb46c..98d737c9a9 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -4921,16 +4921,13 @@ regmatch ( (colnr_T)STRLEN(regline); } } else { - if (has_mbyte) { - const char_u *const line = - reg_getline(behind_pos.rs_u.pos.lnum); + const char_u *const line = + reg_getline(behind_pos.rs_u.pos.lnum); - rp->rs_un.regsave.rs_u.pos.col -= - (*mb_head_off)(line, line - + rp->rs_un.regsave.rs_u.pos.col - 1) + 1; - } else { - rp->rs_un.regsave.rs_u.pos.col--; - } + rp->rs_un.regsave.rs_u.pos.col -= + utf_head_off(line, + line + rp->rs_un.regsave.rs_u.pos.col - 1) + + 1; } } else { if (rp->rs_un.regsave.rs_u.ptr == regline) { -- cgit