mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 12:45:17 -07:00
vim-patch:9.0.2113: Coverity warns for another overflow in shift_line()
Problem: Coverity warns for another overflow in shift_line()
Solution: Test for INT_MAX after the if condition, cast integer values
to (long long) before multiplying.
22a97fc241
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
2336389d23
commit
ac230370f3
@ -296,19 +296,19 @@ void shift_line(bool left, bool round, int amount, int call_changed_bytes)
|
|||||||
} else {
|
} else {
|
||||||
i += amount;
|
i += amount;
|
||||||
}
|
}
|
||||||
count = i * sw_val;
|
count = (int64_t)i * (int64_t)sw_val;
|
||||||
} else { // original vi indent
|
} else { // original vi indent
|
||||||
if (left) {
|
if (left) {
|
||||||
count = MAX(count - sw_val * amount, 0);
|
count = MAX(count - (int64_t)sw_val * (int64_t)amount, 0);
|
||||||
} else {
|
} else {
|
||||||
if ((int64_t)sw_val * (int64_t)amount > INT_MAX - count) {
|
count += (int64_t)sw_val * (int64_t)amount;
|
||||||
count = INT_MAX;
|
|
||||||
} else {
|
|
||||||
count += (int64_t)sw_val * (int64_t)amount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count > INT_MAX) {
|
||||||
|
count = INT_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
// Set new indent
|
// Set new indent
|
||||||
if (State & VREPLACE_FLAG) {
|
if (State & VREPLACE_FLAG) {
|
||||||
change_indent(INDENT_SET, (int)count, false, call_changed_bytes);
|
change_indent(INDENT_SET, (int)count, false, call_changed_bytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user