diff src/charset.c @ 12704:ee5f3f5d3c55 v8.0.1230

patch 8.0.1230: CTRL-A in Visual mode uses character after selection commit https://github.com/vim/vim/commit/ce1577502693940f1f9285cd803a075b738a2330 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 28 16:07:33 2017 +0200 patch 8.0.1230: CTRL-A in Visual mode uses character after selection Problem: CTRL-A in Visual mode uses character after selection. (Nikolai Pavlov) Solution: Check the length before using a character.
author Christian Brabandt <cb@256bit.org>
date Sat, 28 Oct 2017 16:15:04 +0200
parents a99da335b6f1
children 04019fc3de93
line wrap: on
line diff
--- a/src/charset.c
+++ b/src/charset.c
@@ -1852,7 +1852,7 @@ vim_isblankline(char_u *lbuf)
  * If "what" contains STR2NR_OCT recognize octal numbers
  * If "what" contains STR2NR_HEX recognize hex numbers
  * If "what" contains STR2NR_FORCE always assume bin/oct/hex.
- * If maxlen > 0, check at a maximum maxlen chars
+ * If maxlen > 0, check at a maximum maxlen chars.
  */
     void
 vim_str2nr(
@@ -1900,7 +1900,7 @@ vim_str2nr(
 	    if (what & STR2NR_OCT)
 	    {
 		/* Don't interpret "0", "08" or "0129" as octal. */
-		for (n = 1; VIM_ISDIGIT(ptr[n]); ++n)
+		for (n = 1; n != maxlen && VIM_ISDIGIT(ptr[n]); ++n)
 		{
 		    if (ptr[n] > '7')
 		    {
@@ -1908,8 +1908,6 @@ vim_str2nr(
 			break;
 		    }
 		    pre = '0';	/* assume octal */
-		    if (n == maxlen)
-			break;
 		}
 	    }
 	}