diff options
| author | ZyX <kp-pav@yandex.ru> | 2017-04-10 19:12:56 +0300 |
|---|---|---|
| committer | ZyX <kp-pav@yandex.ru> | 2017-04-10 19:12:56 +0300 |
| commit | 22fb9d8d25f5354bb878b953ba49b439961c8476 (patch) | |
| tree | d3c21e80d09f7b1cf1a7c525643c2e20fb5a925e /src/nvim/undo.c | |
| parent | acc52a953b99f78435c34337b8ca9b6716a057a1 (diff) | |
| parent | 9aface8c4d1edd25d4fed3e099e3c2c02b0a282a (diff) | |
| download | rneovim-22fb9d8d25f5354bb878b953ba49b439961c8476.tar.gz rneovim-22fb9d8d25f5354bb878b953ba49b439961c8476.tar.bz2 rneovim-22fb9d8d25f5354bb878b953ba49b439961c8476.zip | |
Merge branch 'master' into 1476-changes
Diffstat (limited to 'src/nvim/undo.c')
| -rw-r--r-- | src/nvim/undo.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 4d4e8d9bb9..571ad7204f 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -76,6 +76,7 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <string.h> #include <fcntl.h> @@ -966,12 +967,12 @@ static u_entry_T *unserialize_uep(bufinfo_T * bi, bool *error, uep->ue_lcount = undo_read_4c(bi); uep->ue_size = undo_read_4c(bi); - char_u **array; + char_u **array = NULL; if (uep->ue_size > 0) { - array = xmalloc(sizeof(char_u *) * (size_t)uep->ue_size); - memset(array, 0, sizeof(char_u *) * (size_t)uep->ue_size); - } else { - array = NULL; + if ((size_t)uep->ue_size < SIZE_MAX / sizeof(char_u *)) { + array = xmalloc(sizeof(char_u *) * (size_t)uep->ue_size); + memset(array, 0, sizeof(char_u *) * (size_t)uep->ue_size); + } } uep->ue_array = array; @@ -1400,7 +1401,9 @@ void u_read_undo(char *name, char_u *hash, char_u *orig_name) // sequence numbers of the headers. // When there are no headers uhp_table is NULL. if (num_head > 0) { - uhp_table = xmalloc((size_t)num_head * sizeof(u_header_T *)); + if ((size_t)num_head < SIZE_MAX / sizeof(*uhp_table)) { + uhp_table = xmalloc((size_t)num_head * sizeof(*uhp_table)); + } } long num_read_uhps = 0; |