[vim] 96/139: patch 7.4.1779 Problem: Using negative index in strcharpart(). (Yegappan Lakshmanan) Solution: Assume single byte when using a negative iindex.

James McCoy jamessan at debian.org
Fri May 6 04:00:10 UTC 2016


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch debian/sid
in repository vim.

commit 73dfe917ba6357413aaf98a021c91add5ac6e9bc
Author: Bram Moolenaar <Bram at vim.org>
Date:   Sat Apr 23 13:54:48 2016 +0200

    patch 7.4.1779
    Problem:    Using negative index in strcharpart(). (Yegappan Lakshmanan)
    Solution:   Assume single byte when using a negative iindex.
---
 src/eval.c    | 7 ++++++-
 src/version.c | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/eval.c b/src/eval.c
index 146348d..a3fe2a2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -19774,7 +19774,12 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
 	    charlen = get_tv_number(&argvars[2]);
 	    while (charlen > 0 && nbyte + len < slen)
 	    {
-		len += mb_char2len(p[nbyte + len]);
+		int off = nbyte + len;
+
+		if (off < 0)
+		    len += 1;
+		else
+		    len += mb_char2len(p[off]);
 		--charlen;
 	    }
 	}
diff --git a/src/version.c b/src/version.c
index 9aa400e..adbb46a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1779,
+/**/
     1778,
 /**/
     1777,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-vim/vim.git



More information about the pkg-vim-maintainers mailing list