diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2024-04-11 09:34:43 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-11 09:34:43 +0800 |
| commit | 7aa56370f326f5f1b3fdfa1c79bbffc7cc6ae267 (patch) | |
| tree | 3e01c5c1e5e883cfa7d517670ac5ab1a10042ac8 /src/nvim/normal.c | |
| parent | 4528a69c8772a5fe182fb293b929dfcfad112abc (diff) | |
| download | rneovim-7aa56370f326f5f1b3fdfa1c79bbffc7cc6ae267.tar.gz rneovim-7aa56370f326f5f1b3fdfa1c79bbffc7cc6ae267.tar.bz2 rneovim-7aa56370f326f5f1b3fdfa1c79bbffc7cc6ae267.zip | |
vim-patch:9.0.2114: overflow detection not accurate when adding digits (#28271)
Problem: overflow detection not accurate when adding digits
Solution: Use a helper function
Use a helper function to better detect overflows before adding integer
digits to a long or an integer variable respectively. Signal the
overflow to the caller function.
closes: vim/vim#13539
https://github.com/vim/vim/commit/22cbc8a4e17ce61aa460c451a26e1bff2c3d2af9
Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/nvim/normal.c')
| -rw-r--r-- | src/nvim/normal.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a95965ad6a..b40a11f6d8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -48,6 +48,7 @@ #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mark_defs.h" +#include "nvim/math.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" @@ -2639,11 +2640,10 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg) if (nchar == K_DEL || nchar == K_KDEL) { n /= 10; } else if (ascii_isdigit(nchar)) { - if (n > INT_MAX / 10) { + if (vim_append_digit_int(&n, nchar - '0') == FAIL) { clearopbeep(cap->oap); break; } - n = n * 10 + (nchar - '0'); } else if (nchar == CAR) { win_setheight(n); break; |