action = *act;
}
- if (l != NULL && set_errorlist(wp, l, action, NULL) == OK)
+ if (l != NULL && set_errorlist(wp, l, action,
+ (char_u *)(wp == NULL ? "setqflist()" : "setloclist()")) == OK)
rettv->vval.v_number = 0;
}
#endif
int idx;
{
qfline_T *qfp;
+ int stop = FALSE;
while (qi->qf_lists[idx].qf_count)
{
qfp = qi->qf_lists[idx].qf_start->qf_next;
- if (qi->qf_lists[idx].qf_title != NULL)
+ if (qi->qf_lists[idx].qf_title != NULL && !stop)
{
vim_free(qi->qf_lists[idx].qf_start->qf_text);
+ stop = (qi->qf_lists[idx].qf_start == qfp);
vim_free(qi->qf_lists[idx].qf_start->qf_pattern);
vim_free(qi->qf_lists[idx].qf_start);
+ if (stop)
+ /* Somehow qf_count may have an incorrect value, set it to 1
+ * to avoid crashing when it's wrong.
+ * TODO: Avoid qf_count being incorrect. */
+ qi->qf_lists[idx].qf_count = 1;
}
qi->qf_lists[idx].qf_start = qfp;
--qi->qf_lists[idx].qf_count;