# HG changeset patch # User Bram Moolenaar # Date 1661368503 -7200 # Node ID 256418aa72edb8f30aa69d3a9f09b70b41b55098 # Parent 9679c317a980be82885c87798e0f1696ec2e1886 patch 9.0.0260: using freed memory when using 'quickfixtextfunc' recursively Commit: https://github.com/vim/vim/commit/d6c67629ed05aae436164eec474832daf8ba7420 Author: Bram Moolenaar Date: Wed Aug 24 20:07:22 2022 +0100 patch 9.0.0260: using freed memory when using 'quickfixtextfunc' recursively Problem: Using freed memory when using 'quickfixtextfunc' recursively. Solution: Do not allow for recursion. diff --git a/src/quickfix.c b/src/quickfix.c --- a/src/quickfix.c +++ b/src/quickfix.c @@ -4674,6 +4674,11 @@ call_qftf_func(qf_list_T *qfl, int qf_wi { callback_T *cb = &qftf_cb; list_T *qftf_list = NULL; + static int recursive = FALSE; + + if (recursive) + return NULL; // this doesn't work properly recursively + recursive = TRUE; // If 'quickfixtextfunc' is set, then use the user-supplied function to get // the text to display. Use the local value of 'quickfixtextfunc' if it is @@ -4688,7 +4693,10 @@ call_qftf_func(qf_list_T *qfl, int qf_wi // create the dict argument if ((d = dict_alloc_lock(VAR_FIXED)) == NULL) + { + recursive = FALSE; return NULL; + } dict_add_number(d, "quickfix", (long)IS_QF_LIST(qfl)); dict_add_number(d, "winid", (long)qf_winid); dict_add_number(d, "id", (long)qfl->qf_id); @@ -4711,6 +4719,7 @@ call_qftf_func(qf_list_T *qfl, int qf_wi dict_unref(d); } + recursive = FALSE; return qftf_list; } diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -6351,4 +6351,17 @@ func Test_qflist_statusmsg() %bw! endfunc +func Test_quickfixtextfunc_recursive() + func s:QFTfunc(o) + cgete '0' + endfunc + copen + let &quickfixtextfunc = 's:QFTfunc' + cex "" + + let &quickfixtextfunc = '' + cclose +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -732,6 +732,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 260, +/**/ 259, /**/ 258,