From 22cbc8a4e17ce61aa460c451a26e1bff2c3d2af9 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Sun, 19 Nov 2023 10:47:21 +0100 Subject: patch 9.0.2114: overflow detection not accurate when adding digits 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: #13539 Signed-off-by: Christian Brabandt Signed-off-by: Michael Henry Signed-off-by: Ernie Rael --- src/normal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/normal.c') diff --git a/src/normal.c b/src/normal.c index 16b4b45069..61a19c13a4 100644 --- a/src/normal.c +++ b/src/normal.c @@ -2563,12 +2563,11 @@ nv_z_get_count(cmdarg_T *cap, int *nchar_arg) n /= 10; else if (VIM_ISDIGIT(nchar)) { - if (n > LONG_MAX / 10) + if (vim_append_digit_long(&n, nchar - '0') == FAIL) { clearopbeep(cap->oap); break; } - n = n * 10 + (nchar - '0'); } else if (nchar == CAR) { -- cgit v1.2.3