comparison src/quickfix.c @ 26518:13ba00ef7687 v8.2.3788

patch 8.2.3788: lambda for option that is a function may be freed Commit: https://github.com/vim/vim/commit/6ae8fae8696623b527c7fb22567f6a3705b2f0dd Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Dec 12 16:26:44 2021 +0000 patch 8.2.3788: lambda for option that is a function may be freed Problem: Lambda for option that is a function may be garbage collected. Solution: Set a reference in the funcref. (Yegappan Lakshmanan, closes #9330)
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 Dec 2021 17:30:04 +0100
parents c0cb28384dc2
children fac6673086df
comparison
equal deleted inserted replaced
26517:7dfc4c45f698 26518:13ba00ef7687
7673 7673
7674 return retval; 7674 return retval;
7675 } 7675 }
7676 7676
7677 /* 7677 /*
7678 * Mark the context as in use for all the lists in a quickfix stack. 7678 * Mark the quickfix context and callback function as in use for all the lists
7679 * in a quickfix stack.
7679 */ 7680 */
7680 static int 7681 static int
7681 mark_quickfix_ctx(qf_info_T *qi, int copyID) 7682 mark_quickfix_ctx(qf_info_T *qi, int copyID)
7682 { 7683 {
7683 int i; 7684 int i;
7684 int abort = FALSE; 7685 int abort = FALSE;
7685 typval_T *ctx; 7686 typval_T *ctx;
7687 callback_T *cb;
7686 7688
7687 for (i = 0; i < LISTCOUNT && !abort; ++i) 7689 for (i = 0; i < LISTCOUNT && !abort; ++i)
7688 { 7690 {
7689 ctx = qi->qf_lists[i].qf_ctx; 7691 ctx = qi->qf_lists[i].qf_ctx;
7690 if (ctx != NULL && ctx->v_type != VAR_NUMBER 7692 if (ctx != NULL && ctx->v_type != VAR_NUMBER
7691 && ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT) 7693 && ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT)
7692 abort = set_ref_in_item(ctx, copyID, NULL, NULL); 7694 abort = abort || set_ref_in_item(ctx, copyID, NULL, NULL);
7695
7696 cb = &qi->qf_lists[i].qftf_cb;
7697 abort = abort || set_ref_in_callback(cb, copyID);
7693 } 7698 }
7694 7699
7695 return abort; 7700 return abort;
7696 } 7701 }
7697 7702
7705 int abort = FALSE; 7710 int abort = FALSE;
7706 tabpage_T *tp; 7711 tabpage_T *tp;
7707 win_T *win; 7712 win_T *win;
7708 7713
7709 abort = mark_quickfix_ctx(&ql_info, copyID); 7714 abort = mark_quickfix_ctx(&ql_info, copyID);
7715 if (abort)
7716 return abort;
7717
7718 abort = set_ref_in_callback(&qftf_cb, copyID);
7710 if (abort) 7719 if (abort)
7711 return abort; 7720 return abort;
7712 7721
7713 FOR_ALL_TAB_WINDOWS(tp, win) 7722 FOR_ALL_TAB_WINDOWS(tp, win)
7714 { 7723 {