patch 8.2.2406: Vim9: profiled :def function leaks memory
Problem: Vim9: profiled :def function leaks memory.
Solution: Delete the profiled instructions.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 9497782..2dd3a4f 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -8837,6 +8837,15 @@
VIM_CLEAR(dfunc->df_instr);
dfunc->df_instr = NULL;
}
+#ifdef FEAT_PROFILE
+ if (dfunc->df_instr_prof != NULL)
+ {
+ for (idx = 0; idx < dfunc->df_instr_prof_count; ++idx)
+ delete_instr(dfunc->df_instr_prof + idx);
+ VIM_CLEAR(dfunc->df_instr_prof);
+ dfunc->df_instr_prof = NULL;
+ }
+#endif
if (mark_deleted)
dfunc->df_deleted = TRUE;