mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.0048: vim_str2nr() on numbers close to max #9744
Problem: vim_str2nr() does not handle numbers close to the maximum.
Solution: Check for overflow more precisely. (Ken Takata, closes vim/vim#2746)
07ccf7ce7f
This commit is contained in:
parent
027a2157d3
commit
d86c816f8c
@ -1777,9 +1777,12 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
|
||||
#define PARSE_NUMBER(base, cond, conv) \
|
||||
do { \
|
||||
while (!STRING_ENDED(ptr) && (cond)) { \
|
||||
const uvarnumber_T digit = (uvarnumber_T)(conv); \
|
||||
/* avoid ubsan error for overflow */ \
|
||||
if (un < UVARNUMBER_MAX / base) { \
|
||||
un = base * un + (uvarnumber_T)(conv); \
|
||||
if (un < UVARNUMBER_MAX / base \
|
||||
|| (un == UVARNUMBER_MAX / base \
|
||||
&& (base != 10 || digit <= UVARNUMBER_MAX % 10))) { \
|
||||
un = base * un + digit; \
|
||||
} else { \
|
||||
un = UVARNUMBER_MAX; \
|
||||
} \
|
||||
|
Loading…
Reference in New Issue
Block a user