From 0c9f7f5f96d6fedd2c5d9ec235c8b341f47c06f8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 3 Jun 2024 05:35:02 +0800 Subject: 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 --- src/nvim/ops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 8ae1d70882..74c6e83495 100644 --- 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 -- cgit