fix(diagnostic): check if delete failed in qf_fill_buffer() (#25932)

When the contents of a quickfix buffer are replaced, there is a chance
that deletion of the previous lines fails. This ensures that we don't
get stuck in an infinite loop of retrying.

Fix #25402
This commit is contained in:
voidiz 2023-11-08 02:23:13 +01:00 committed by GitHub
parent 1c71c32b29
commit 3d8f0cb695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4135,7 +4135,12 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q
// delete all existing lines
while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) {
(void)ml_delete((linenr_T)1, false);
// If deletion fails, this loop may run forever, so
// signal error and return.
if (ml_delete((linenr_T)1, false) == FAIL) {
internal_error("qf_fill_buffer()");
return;
}
}
}