Skip to content

Commit 73dfe91

Browse files
committed
patch 7.4.1779
Problem: Using negative index in strcharpart(). (Yegappan Lakshmanan) Solution: Assume single byte when using a negative iindex.
1 parent b2fa54a commit 73dfe91

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/eval.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19774,7 +19774,12 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
1977419774
charlen = get_tv_number(&argvars[2]);
1977519775
while (charlen > 0 && nbyte + len < slen)
1977619776
{
19777-
len += mb_char2len(p[nbyte + len]);
19777+
int off = nbyte + len;
19778+
19779+
if (off < 0)
19780+
len += 1;
19781+
else
19782+
len += mb_char2len(p[off]);
1977819783
--charlen;
1977919784
}
1978019785
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ static char *(features[]) =
753753

754754
static int included_patches[] =
755755
{ /* Add new patch number below this line */
756+
/**/
757+
1779,
756758
/**/
757759
1778,
758760
/**/

0 commit comments

Comments
 (0)