aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-14 05:58:32 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-07-14 06:12:42 +0800
commit5531c95101b7656416c97acdd4acb3173d09f64c (patch)
tree7d210309947cb692c28360c97566cbd451cf1803 /src
parent6276fce11e1d1d344f988ebfc8857df7d4f1a8bd (diff)
downloadrneovim-5531c95101b7656416c97acdd4acb3173d09f64c.tar.gz
rneovim-5531c95101b7656416c97acdd4acb3173d09f64c.tar.bz2
rneovim-5531c95101b7656416c97acdd4acb3173d09f64c.zip
vim-patch:8.2.4065: computation overflow with large cound for :yank
Problem: Computation overflow with large cound for :yank. Solution: Avoid an overflow. https://github.com/vim/vim/commit/3cf21b305104e91a28e4ce3a473672b2e88a9469 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index f66464fa3a..63e7a80e53 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1411,7 +1411,11 @@ void set_cmd_count(exarg_T *eap, linenr_T count, bool validate)
}
} else {
eap->line1 = eap->line2;
- eap->line2 += count - 1;
+ if (eap->line2 >= INT32_MAX - (count - 1)) {
+ eap->line2 = INT32_MAX;
+ } else {
+ eap->line2 += count - 1;
+ }
eap->addr_count++;
// Be vi compatible: no error message for out of range.
if (validate && eap->line2 > curbuf->b_ml.ml_line_count) {
@@ -1429,7 +1433,7 @@ static int parse_count(exarg_T *eap, const char **errormsg, bool validate)
if ((eap->argt & EX_COUNT) && ascii_isdigit(*eap->arg)
&& (!(eap->argt & EX_BUFNAME) || *(p = skipdigits(eap->arg + 1)) == NUL
|| ascii_iswhite(*p))) {
- linenr_T n = getdigits_int32(&eap->arg, false, -1);
+ linenr_T n = getdigits_int32(&eap->arg, false, INT32_MAX);
eap->arg = skipwhite(eap->arg);
if (eap->args != NULL) {