mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.1.1303: missing out-of-memory check in linematch.c (#33487)
Problem: missing out-of-memory check in linematch.c Solution: return early in case of memory allocation failure, move the pow() calculation ouside of the for() loop (John Marriott) closes: vim/vim#171182137710b43
Co-authored-by: John Marriott <basilisk@internode.on.net> (cherry picked from commitd2d1b5e944
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
4d87229789
commit
b694131c3b
@@ -345,10 +345,11 @@ size_t linematch_nbuffers(const mmfile_t **diff_blk, const int *diff_len, const
|
||||
// create the flattened path matrix
|
||||
diffcmppath_T *diffcmppath = xmalloc(sizeof(diffcmppath_T) * memsize);
|
||||
// allocate memory here
|
||||
size_t n = (size_t)pow(2.0, (double)ndiffs);
|
||||
for (size_t i = 0; i < memsize; i++) {
|
||||
diffcmppath[i].df_lev_score = 0;
|
||||
diffcmppath[i].df_path_n = 0;
|
||||
for (size_t j = 0; j < (size_t)pow(2, (double)ndiffs); j++) {
|
||||
for (size_t j = 0; j < n; j++) {
|
||||
diffcmppath[i].df_choice_mem[j] = -1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user