Skip to content

Commit

Permalink
vim-patch:8.1.0229: crash when dumping profiling data neovim#10428
Browse files Browse the repository at this point in the history
Problem:    Crash when dumping profiling data.
Solution:   Reset flag indicating that initialization was done.
vim/vim@79c2ad5
  • Loading branch information
blueyed authored and justinmk committed Jul 5, 2019
1 parent 7535f84 commit 3c860e2
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/nvim/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -21256,9 +21256,10 @@ void ex_function(exarg_T *eap)
overwrite = true;
} else {
// redefine existing function
ga_clear_strings(&(fp->uf_args));
ga_clear_strings(&(fp->uf_lines));
XFREE_CLEAR(name);
func_clear_items(fp);
fp->uf_profiling = false;
fp->uf_prof_initialized = false;
}
}
} else {
Expand Down Expand Up @@ -21353,12 +21354,9 @@ void ex_function(exarg_T *eap)
} else {
fp->uf_scoped = NULL;
}
fp->uf_tml_count = NULL;
fp->uf_tml_total = NULL;
fp->uf_tml_self = NULL;
fp->uf_profiling = FALSE;
if (prof_def_func())
if (prof_def_func()) {
func_do_profile(fp);
}
fp->uf_varargs = varargs;
if (sandbox) {
flags |= FC_SANDBOX;
Expand Down Expand Up @@ -22210,6 +22208,19 @@ static bool func_remove(ufunc_T *fp)
return false;
}

static void func_clear_items(ufunc_T *fp)
{
ga_clear_strings(&(fp->uf_args));
ga_clear_strings(&(fp->uf_lines));

xfree(fp->uf_tml_count);
fp->uf_tml_count = NULL;
xfree(fp->uf_tml_total);
fp->uf_tml_total = NULL;
xfree(fp->uf_tml_self);
fp->uf_tml_self = NULL;
}

/// Free all things that a function contains. Does not free the function
/// itself, use func_free() for that.
///
Expand All @@ -22222,11 +22233,7 @@ static void func_clear(ufunc_T *fp, bool force)
fp->uf_cleared = true;

// clear this function
ga_clear_strings(&(fp->uf_args));
ga_clear_strings(&(fp->uf_lines));
xfree(fp->uf_tml_count);
xfree(fp->uf_tml_total);
xfree(fp->uf_tml_self);
func_clear_items(fp);
funccal_unref(fp->uf_scoped, fp, force);
}

Expand Down

0 comments on commit 3c860e2

Please sign in to comment.