aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-03 05:35:02 +0800
committerGitHub <noreply@github.com>2024-06-03 05:35:02 +0800
commit0c9f7f5f96d6fedd2c5d9ec235c8b341f47c06f8 (patch)
tree90df05cf073db934ad0e86fe469d199fd9e1fe1c /src
parent659d3dcd2edf1b178a20015cab399390ffda1a32 (diff)
downloadrneovim-0c9f7f5f96d6fedd2c5d9ec235c8b341f47c06f8.tar.gz
rneovim-0c9f7f5f96d6fedd2c5d9ec235c8b341f47c06f8.tar.bz2
rneovim-0c9f7f5f96d6fedd2c5d9ec235c8b341f47c06f8.zip
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 (limited to 'src')
-rw-r--r--src/nvim/ops.c6
1 files changed, 4 insertions, 2 deletions
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