mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
vim-patch:8.2.3659: integer overflow with large line number
Problem: Integer overflow with large line number.
Solution: Check for overflow. (closes vim/vim#9202)
03725c5795
Put E1247 in globals.h as E1240 is also there.
Do not make getdigits() abort.
This commit is contained in:
@@ -824,15 +824,12 @@ static bool normal_get_command_count(NormalState *s)
|
||||
if (s->c == K_DEL || s->c == K_KDEL) {
|
||||
s->ca.count0 /= 10;
|
||||
del_from_showcmd(4); // delete the digit and ~@%
|
||||
} else if (s->ca.count0 >= 999999999L) {
|
||||
s->ca.count0 = 999999999L;
|
||||
} else {
|
||||
s->ca.count0 = s->ca.count0 * 10 + (s->c - '0');
|
||||
}
|
||||
|
||||
if (s->ca.count0 < 0) {
|
||||
// overflow
|
||||
s->ca.count0 = 999999999L;
|
||||
}
|
||||
|
||||
// Set v:count here, when called from main() and not a stuffed
|
||||
// command, so that v:count can be used in an expression mapping
|
||||
// right after the count. Do set it for redo.
|
||||
@@ -1046,14 +1043,14 @@ static int normal_execute(VimState *state, int key)
|
||||
// If you give a count before AND after the operator, they are
|
||||
// multiplied.
|
||||
if (s->ca.count0) {
|
||||
s->ca.count0 = (long)((uint64_t)s->ca.count0 * (uint64_t)s->ca.opcount);
|
||||
if (s->ca.opcount >= 999999999L / s->ca.count0) {
|
||||
s->ca.count0 = 999999999L;
|
||||
} else {
|
||||
s->ca.count0 *= s->ca.opcount;
|
||||
}
|
||||
} else {
|
||||
s->ca.count0 = s->ca.opcount;
|
||||
}
|
||||
if (s->ca.count0 < 0) {
|
||||
// overflow
|
||||
s->ca.count0 = 999999999L;
|
||||
}
|
||||
}
|
||||
|
||||
// Always remember the count. It will be set to zero (on the next call,
|
||||
|
Reference in New Issue
Block a user