diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-01-10 08:56:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 08:56:38 +0100 |
commit | 6d8b5989bc84c0b54cb6804af0851cb3322234b2 (patch) | |
tree | 60e0d4b164ae981c1ed71a333c3fd0df8bee8e54 /src/nvim/indent.c | |
parent | 57c7e1d4a0d7285d9de5b9035e91f546654268da (diff) | |
parent | fc4ca5bdd8c5a2b37b6efe34a9b32a1bd75c57af (diff) | |
download | rneovim-6d8b5989bc84c0b54cb6804af0851cb3322234b2.tar.gz rneovim-6d8b5989bc84c0b54cb6804af0851cb3322234b2.tar.bz2 rneovim-6d8b5989bc84c0b54cb6804af0851cb3322234b2.zip |
Merge #9472 from justinmk/pvs-warnings2
Diffstat (limited to 'src/nvim/indent.c')
-rw-r--r-- | src/nvim/indent.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 7c3f354c13..13534ac1a9 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -6,6 +6,7 @@ #include <stdbool.h> #include "nvim/ascii.h" +#include "nvim/assert.h" #include "nvim/indent.h" #include "nvim/eval.h" #include "nvim/charset.h" @@ -204,7 +205,12 @@ int set_indent(int size, int flags) // after the if (!curbuf->b_p_et) below. if (orig_char_len != -1) { assert(orig_char_len + size - ind_done + line_len >= 0); - newline = xmalloc((size_t)(orig_char_len + size - ind_done + line_len)); + size_t n; // = orig_char_len + size - ind_done + line_len + size_t n2; + STRICT_ADD(orig_char_len, size, &n, size_t); + STRICT_ADD(ind_done, line_len, &n2, size_t); + STRICT_SUB(n, n2, &n, size_t); + newline = xmalloc(n); todo = size - ind_done; // Set total length of indent in characters, which may have been @@ -226,7 +232,9 @@ int set_indent(int size, int flags) } else { todo = size; assert(ind_len + line_len >= 0); - newline = xmalloc((size_t)(ind_len + line_len)); + size_t newline_size; + STRICT_ADD(ind_len, line_len, &newline_size, size_t); + newline = xmalloc(newline_size); s = newline; } @@ -392,7 +400,9 @@ int copy_indent(int size, char_u *src) // and the rest of the line. line_len = (int)STRLEN(get_cursor_line_ptr()) + 1; assert(ind_len + line_len >= 0); - line = xmalloc((size_t)(ind_len + line_len)); + size_t line_size; + STRICT_ADD(ind_len, line_len, &line_size, size_t); + line = xmalloc(line_size); p = line; } } |