neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 0c9f7f5f96d6fedd2c5d9ec235c8b341f47c06f8
parent 659d3dcd2edf1b178a20015cab399390ffda1a32
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Mon,  3 Jun 2024 05:35:02 +0800

vim-patch:9.1.0458: Coverity complains about division by zero (#29149)

Problem:  Coverity complains about division by zero
Solution: Check explicitly for sw_val being zero

Shouldn't happen, since tabstop value should always be larger than zero.
So just add this as a safety measure.

https://github.com/vim/vim/commit/7737ce519b9cba8ef135154d76b69f715b1a0b4d

Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat:
Msrc/nvim/ops.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/nvim/ops.c b/src/nvim/ops.c @@ -282,8 +282,10 @@ void op_shift(oparg_T *oap, bool curs_top, int amount) /// @param call_changed_bytes call changed_bytes() void shift_line(bool left, bool round, int amount, int call_changed_bytes) { - const int sw_val = get_sw_value_indent(curbuf, left); - + int sw_val = get_sw_value_indent(curbuf, left); + if (sw_val == 0) { + sw_val = 1; // shouldn't happen, just in case + } int count = get_indent(); // get current indent if (round) { // round off indent