mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.1.0608: Coverity warns about a few potential issues
Problem: Coverity warns about a few potential issues Solution: Fix those issues (see details below) 1) Fix overflow warning in highlight.c This happens because we are comparing int with long and assign a potential long value to an int, which could cause an overflow. So add some casts to ensure the value fits into an int. 2) Fix Overflow warning in shift_line(). This happens because we are performing a division/modulo operation of a long type by an int type and assign the result to an int, which could then overflow. So before performing the operation, trim the long to value to at most max int value, so that it can't overflow. 3) Fix overflow warning in syn_list_cluster in syntax.c This is essential the same issue as 1) 4) not checking the return value of vim_mkdir() in spellfile.c Creating the spell directory could fail. Handle this case and return early in this case. 5) qsort() may deref a NULL pointer when fuzzy match does not return a result. Fix this by checking that the accessed growarray fuzzy_indices actually contains data. If not we can silently skip the qsort() and related logic. closes: #15284 Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -240,8 +240,8 @@ shift_line(
|
||||
|
||||
if (round) // round off indent
|
||||
{
|
||||
i = count / sw_val; // number of 'shiftwidth' rounded down
|
||||
j = count % sw_val; // extra spaces
|
||||
i = trim_to_int(count) / sw_val; // number of 'shiftwidth' rounded down
|
||||
j = trim_to_int(count) % sw_val; // extra spaces
|
||||
if (j && left) // first remove extra spaces
|
||||
--amount;
|
||||
if (left)
|
||||
|
Reference in New Issue
Block a user