diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-04-27 09:25:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 09:25:02 +0200 |
commit | 53f11dcfc7139fe6c8a6b114db4bfec5d91005a9 (patch) | |
tree | e9bfbaf10fc6681bbbcba0a0eabdce8a6f6840b5 /src/nvim/strings.c | |
parent | 009ccfe170ada2c78ca7feabda567a7e901fb30b (diff) | |
parent | 4ce8521ee4a72e050bd187c2986708c5f98c7442 (diff) | |
download | rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.tar.gz rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.tar.bz2 rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.zip |
Merge #8218 'Fix errors reported by PVS'
closes #4983
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r-- | src/nvim/strings.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index e3f6a8cbf6..b3a0e4816b 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -1145,8 +1145,8 @@ int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap, f, uarg); break; } - assert(str_arg_l < sizeof(tmp)); } + assert(str_arg_l < sizeof(tmp)); // include the optional minus sign and possible "0x" in the region // before the zero padding insertion point @@ -1376,16 +1376,14 @@ int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap, } // insert zero padding as requested by precision or min field width - if (number_of_zeros_to_pad > 0) { - size_t zn = number_of_zeros_to_pad; - if (str_avail) { - size_t avail = str_m - str_l; - memset(str + str_l, '0', MIN(zn, avail)); - str_avail = zn < avail; - } - assert(zn <= SIZE_MAX - str_l); - str_l += zn; + size_t zn = number_of_zeros_to_pad; + if (str_avail) { + size_t avail = str_m - str_l; + memset(str + str_l, '0', MIN(zn, avail)); + str_avail = zn < avail; } + assert(zn <= SIZE_MAX - str_l); + str_l += zn; } // insert formatted string |