diff options
| author | bfredl <bjorn.linse@gmail.com> | 2022-01-08 16:47:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-08 16:47:23 +0100 |
| commit | 9386fca597cdb6ecf0da827676dd5b5554b73f69 (patch) | |
| tree | 372da7090d03076dd79136bd9ba9c94a6d72be19 /src/nvim/memfile.c | |
| parent | e70ea6ea20915865939d5199a18aebf68b67a708 (diff) | |
| parent | 3fccdeb326f5633d3c84b98ac1bd0b15b7fd28a5 (diff) | |
| download | rneovim-9386fca597cdb6ecf0da827676dd5b5554b73f69.tar.gz rneovim-9386fca597cdb6ecf0da827676dd5b5554b73f69.tar.bz2 rneovim-9386fca597cdb6ecf0da827676dd5b5554b73f69.zip | |
Merge pull request #16848 from dundargoc/refactor/prevent-overflow-by-casting
refactor: avoid overflow by explicitly casting operand to a wider type
Diffstat (limited to 'src/nvim/memfile.c')
| -rw-r--r-- | src/nvim/memfile.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 3397296b3a..2a72d1e6a0 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -247,7 +247,7 @@ bhdr_T *mf_new(memfile_T *mfp, bool negative, unsigned page_count) } else { // need to allocate memory for this block // If the number of pages matches use the bhdr_T from the free list and // allocate the data. - void *p = xmalloc(mfp->mf_page_size * page_count); + void *p = xmalloc((size_t)mfp->mf_page_size * page_count); hp = mf_rem_free(mfp); hp->bh_data = p; } @@ -269,7 +269,7 @@ bhdr_T *mf_new(memfile_T *mfp, bool negative, unsigned page_count) // Init the data to all zero, to avoid reading uninitialized data. // This also avoids that the passwd file ends up in the swap file! - (void)memset(hp->bh_data, 0, mfp->mf_page_size * page_count); + (void)memset(hp->bh_data, 0, (size_t)mfp->mf_page_size * page_count); return hp; } @@ -528,7 +528,7 @@ bool mf_release_all(void) static bhdr_T *mf_alloc_bhdr(memfile_T *mfp, unsigned page_count) { bhdr_T *hp = xmalloc(sizeof(bhdr_T)); - hp->bh_data = xmalloc(mfp->mf_page_size * page_count); + hp->bh_data = xmalloc((size_t)mfp->mf_page_size * page_count); hp->bh_page_count = page_count; return hp; } |
