aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-05-09 17:22:08 -0400
committerGitHub <noreply@github.com>2020-05-09 17:22:08 -0400
commit9816173fb3bdd7b42943ff770ddcd5c953a77163 (patch)
tree1e07e730d898d469d1154aefc289ca7074eea91c /src
parent2f818eb9ee6a17ec5897f28e167248efb02f1c0e (diff)
parent7872877ce537389df6fb461bfda23c823acca5fe (diff)
downloadrneovim-9816173fb3bdd7b42943ff770ddcd5c953a77163.tar.gz
rneovim-9816173fb3bdd7b42943ff770ddcd5c953a77163.tar.bz2
rneovim-9816173fb3bdd7b42943ff770ddcd5c953a77163.zip
Merge #12275 from erw7/profile-fix-use-after-free
viml/profile: fix missing fixes when merging vim-patch:8.1.0130 Fix #12255 ### Steps to reproduce using `nvim -u NORC` ``` nvim -u NORC :function Test() :endfunction :profile start log1 :profile func Test :call Test() :profile stop :profile start log2 :profile func Test :call Test() :profile stop ``` ### Actual behaviour #### log1 ``` FUNCTION Test() Called 1 times ... ``` #### log2 ``` FUNCTION Test() Called 2 times ... ``` ### Expected behaviour #### log1 ``` FUNCTION Test() Called 1 times ... ``` #### log2 ``` FUNCTION Test() Called 1 times ... ```
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds2.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index fbdd64e43e..9f4055af8d 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1038,16 +1038,17 @@ static void profile_reset(void)
if (!HASHITEM_EMPTY(hi)) {
n--;
ufunc_T *uf = HI2UF(hi);
- if (uf->uf_profiling) {
+ if (uf->uf_prof_initialized) {
uf->uf_profiling = 0;
uf->uf_tm_count = 0;
uf->uf_tm_total = profile_zero();
uf->uf_tm_self = profile_zero();
uf->uf_tm_children = profile_zero();
- XFREE_CLEAR(uf->uf_tml_count);
- XFREE_CLEAR(uf->uf_tml_total);
- XFREE_CLEAR(uf->uf_tml_self);
+ for (int i = 0; i < uf->uf_lines.ga_len; i++) {
+ uf->uf_tml_count[i] = 0;
+ uf->uf_tml_total[i] = uf->uf_tml_self[i] = 0;
+ }
uf->uf_tml_start = profile_zero();
uf->uf_tml_children = profile_zero();