diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-20 14:17:18 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-20 14:17:18 +0100 |
commit | cdef1cefa2a440911c727558562f83ed9b00e16b (patch) | |
tree | af1594f84e5951aa45d9f4abad902a616bcd6a1d /src/eval.c | |
parent | 43625762a9751cc6e6e4d8f54fbc8b82d98fb20d (diff) |
patch 9.0.0804: crash when trying to divide a number by -1v9.0.0804
Problem: Crash when trying to divice the largest negative number by -1.
Solution: Handle this case specifically.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index 1652fcb4ae..062fab0ac9 100644 --- a/src/eval.c +++ b/src/eval.c @@ -66,6 +66,12 @@ num_divide(varnumber_T n1, varnumber_T n2, int *failed) else result = VARNUM_MAX; } + else if (n1 == VARNUM_MIN && n2 == -1) + { + // specific case: trying to do VARNUM_MIN / -1 results in a positive + // number that doesn't fit in varnumber_T and causes an FPE + result = VARNUM_MAX; + } else result = n1 / n2; @@ -6023,7 +6029,7 @@ var2fpos( } /* - * Convert list in "arg" into position "psop" and optional file number "fnump". + * Convert list in "arg" into position "posp" and optional file number "fnump". * When "fnump" is NULL there is no file number, only 3 items: [lnum, col, off] * Note that the column is passed on as-is, the caller may want to decrement * it to use 1 for the first column. |