From 3d8f0cb695a5ea97ea05bc7decb19bb047cb753d Mon Sep 17 00:00:00 2001 From: voidiz <29259387+voidiz@users.noreply.github.com> Date: Wed, 8 Nov 2023 02:23:13 +0100 Subject: [PATCH] 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 --- src/nvim/quickfix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 2e3cc4f170..61157301b6 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -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; + } } }