diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-02-18 10:15:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-18 10:15:08 +0800 |
commit | faeff49cbfd190afba67e221412b7132b7ad8360 (patch) | |
tree | bb6260556f056982e51f6dda99bd882e650cafcc /src/nvim/normal.c | |
parent | 592f4a7c0807427355635eb371215036325e5bb8 (diff) | |
parent | 62a1290758a3cd6af95dc47a3bbdc7dcf290d531 (diff) | |
download | rneovim-faeff49cbfd190afba67e221412b7132b7ad8360.tar.gz rneovim-faeff49cbfd190afba67e221412b7132b7ad8360.tar.bz2 rneovim-faeff49cbfd190afba67e221412b7132b7ad8360.zip |
Merge pull request #17449 from zeertzjq/vim-8.2.3659
vim-patch:8.2.{3659,3660,3661}: integer overflow with large line number
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 21c465434a..7fe6469527 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -824,15 +824,12 @@ static bool normal_get_command_count(NormalState *s) if (s->c == K_DEL || s->c == K_KDEL) { s->ca.count0 /= 10; del_from_showcmd(4); // delete the digit and ~@% + } else if (s->ca.count0 > 99999999L) { + s->ca.count0 = 999999999L; } else { s->ca.count0 = s->ca.count0 * 10 + (s->c - '0'); } - if (s->ca.count0 < 0) { - // overflow - s->ca.count0 = 999999999L; - } - // Set v:count here, when called from main() and not a stuffed // command, so that v:count can be used in an expression mapping // right after the count. Do set it for redo. @@ -1046,14 +1043,14 @@ static int normal_execute(VimState *state, int key) // If you give a count before AND after the operator, they are // multiplied. if (s->ca.count0) { - s->ca.count0 = (long)((uint64_t)s->ca.count0 * (uint64_t)s->ca.opcount); + if (s->ca.opcount >= 999999999L / s->ca.count0) { + s->ca.count0 = 999999999L; + } else { + s->ca.count0 *= s->ca.opcount; + } } else { s->ca.count0 = s->ca.opcount; } - if (s->ca.count0 < 0) { - // overflow - s->ca.count0 = 999999999L; - } } // Always remember the count. It will be set to zero (on the next call, |