Merge pull request #26860 from sus-domesticus/fix/clangd

fix/clangd (check size of array before applying qsort on it; set block pointer to null in case map is empty)
This commit is contained in:
zeertzjq 2024-01-03 06:57:23 +08:00 committed by GitHub
commit ee21273634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -391,7 +391,7 @@ int mf_sync(memfile_T *mfp, int flags)
// Then we only try to write blocks within the existing file. If that also
// fails then we give up.
int status = OK;
bhdr_T *hp;
bhdr_T *hp = NULL;
// note, "last" block is typically earlier in the hash list
map_foreach_value(&mfp->mf_hash, hp, {
if (((flags & MFS_ALL) || hp->bh_bnum >= 0)

View File

@ -240,7 +240,9 @@ void win_float_remove(bool bang, int count)
for (win_T *wp = lastwin; wp && wp->w_floating; wp = wp->w_prev) {
kv_push(float_win_arr, wp);
}
qsort(float_win_arr.items, float_win_arr.size, sizeof(win_T *), float_zindex_cmp);
if (float_win_arr.size > 0) {
qsort(float_win_arr.items, float_win_arr.size, sizeof(win_T *), float_zindex_cmp);
}
for (size_t i = 0; i < float_win_arr.size; i++) {
if (win_close(float_win_arr.items[i], false, false) == FAIL) {
break;