patch 8.0.1413: accessing freed memory in :cbuffer
Problem: Accessing freed memory in :cbuffer.
Solution: Get quickfix list after executing autocmds. (closes #2470)
diff --git a/src/quickfix.c b/src/quickfix.c
index 6e80ddf..87c6085 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -5520,14 +5520,6 @@
#endif
int res;
- if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
- || eap->cmdidx == CMD_laddbuffer)
- {
- qi = ll_get_or_alloc_list(curwin);
- if (qi == NULL)
- return;
- }
-
#ifdef FEAT_AUTOCMD
switch (eap->cmdidx)
{
@@ -5549,6 +5541,15 @@
}
#endif
+ /* Must come after autocommands. */
+ if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
+ || eap->cmdidx == CMD_laddbuffer)
+ {
+ qi = ll_get_or_alloc_list(curwin);
+ if (qi == NULL)
+ return;
+ }
+
if (*eap->arg == NUL)
buf = curbuf;
else if (*skipwhite(skipdigits(eap->arg)) == NUL)