diff options
author | James McCoy <jamessan@jamessan.com> | 2016-09-02 10:02:49 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-09-02 10:11:32 -0400 |
commit | a371f1027e443e59a54191b187170b63fcf94a9b (patch) | |
tree | 9fb2ee4d4bdc10c0e65713968cdd6de677b3c776 /src | |
parent | f175b281cf3e6d5287663b79c4a7f705eb83301a (diff) | |
download | rneovim-a371f1027e443e59a54191b187170b63fcf94a9b.tar.gz rneovim-a371f1027e443e59a54191b187170b63fcf94a9b.tar.bz2 rneovim-a371f1027e443e59a54191b187170b63fcf94a9b.zip |
Fix error-handling of strtoimax boundary conditions
strtoimax is only required to set errno if there is an
underflow/overflow. In those conditions, strtoimax returns
INTMAX_MIN/INTMAX_MAX respectively, so that's the only time we should be
checking the value of errno.
Even in those conditions, errno needs to be set to a known good value
before calling strtoimax to differentiate between "value is actually
INTMAX_MAX/MIN" and "value over/underflows".
Closes #5279
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/charset.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 22ca0fb0cc..b5154819b9 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1739,8 +1739,11 @@ char_u* skiptowhite_esc(char_u *p) { /// @return Number read from the string. intmax_t getdigits(char_u **pp) { + errno = 0; intmax_t number = strtoimax((char *)*pp, (char **)pp, 10); - assert(errno != ERANGE); + if (number == INTMAX_MAX || number == INTMAX_MIN) { + assert(errno != ERANGE); + } return number; } |