mirror of
https://github.com/neovim/neovim.git
synced 2025-01-02 17:33:28 -07:00
vim-patch:8.2.2783: duplicate code for setting byte in blob, blob test may fail
Problem: Duplicate code for setting byte in blob, blob test may fail.
Solution: Call blob_set_append(). Test sort failure with "N".
e8209b91b9
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
88b70e7d46
commit
55d30c459c
@ -1620,18 +1620,7 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool
|
|||||||
bool error = false;
|
bool error = false;
|
||||||
const char val = (char)tv_get_number_chk(rettv, &error);
|
const char val = (char)tv_get_number_chk(rettv, &error);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
garray_T *const gap = &lp->ll_blob->bv_ga;
|
tv_blob_set_append(lp->ll_blob, (int)lp->ll_n1, (uint8_t)val);
|
||||||
|
|
||||||
// Allow for appending a byte. Setting a byte beyond
|
|
||||||
// the end is an error otherwise.
|
|
||||||
if (lp->ll_n1 < gap->ga_len || lp->ll_n1 == gap->ga_len) {
|
|
||||||
ga_grow(&lp->ll_blob->bv_ga, 1);
|
|
||||||
tv_blob_set(lp->ll_blob, (int)lp->ll_n1, (uint8_t)val);
|
|
||||||
if (lp->ll_n1 == gap->ga_len) {
|
|
||||||
gap->ga_len++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// error for invalid range was already given in get_lval()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (op != NULL && *op != '=') {
|
} else if (op != NULL && *op != '=') {
|
||||||
|
@ -632,7 +632,7 @@ func Test_blob_sort()
|
|||||||
if has('float')
|
if has('float')
|
||||||
call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:')
|
call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:')
|
||||||
endif
|
endif
|
||||||
call CheckLegacyAndVim9Failure(['call sort(["abc", 0z11], "f")'], 'E892:')
|
call CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" The following used to cause an out-of-bounds memory access
|
" The following used to cause an out-of-bounds memory access
|
||||||
|
Loading…
Reference in New Issue
Block a user