aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2019-08-30 12:27:44 +0900
committererw7 <erw7.github@gmail.com>2019-09-04 14:48:21 +0900
commitd3f1eb3024fa297c970a79dd24ef818e4aeb8525 (patch)
tree391b55d590a4f995bda0d96116c15af23a025008 /src/nvim/eval.c
parent9db60b06a1d9b50b3ba6beb858eb0fd2c58571c4 (diff)
downloadrneovim-d3f1eb3024fa297c970a79dd24ef818e4aeb8525.tar.gz
rneovim-d3f1eb3024fa297c970a79dd24ef818e4aeb8525.tar.bz2
rneovim-d3f1eb3024fa297c970a79dd24ef818e4aeb8525.zip
vim-patch:8.1.1946: memory error when profiling a function without a script ID
Problem: Memory error when profiling a function without a script ID. Solution: Check for missing script ID. (closes vim/vim#4877) https://github.com/vim/vim/commit/163588005da3a240e49416093d0d0251951d60a1
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 6f7d5ed6e4..98448ff1f9 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -22147,16 +22147,18 @@ void func_dump_profile(FILE *fd)
} else {
fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
}
- bool should_free;
- const LastSet last_set = (LastSet){
- .script_ctx = fp->uf_script_ctx,
- .channel_id = 0,
- };
- char_u *p = get_scriptname(last_set, &should_free);
- fprintf(fd, " Defined: %s line %" PRIdLINENR "\n",
- p, fp->uf_script_ctx.sc_lnum);
- if (should_free) {
- xfree(p);
+ if (fp->uf_script_ctx.sc_sid != 0) {
+ bool should_free;
+ const LastSet last_set = (LastSet){
+ .script_ctx = fp->uf_script_ctx,
+ .channel_id = 0,
+ };
+ char_u *p = get_scriptname(last_set, &should_free);
+ fprintf(fd, " Defined: %s line %" PRIdLINENR "\n",
+ p, fp->uf_script_ctx.sc_lnum);
+ if (should_free) {
+ xfree(p);
+ }
}
if (fp->uf_tm_count == 1) {
fprintf(fd, "Called 1 time\n");