diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-30 18:37:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-30 18:37:26 +0200 |
commit | 163588005da3a240e49416093d0d0251951d60a1 (patch) | |
tree | aecfcef01a89c3dc66b9327d6af27404b32fa9cd /src/profiler.c | |
parent | 9e67b6a6a126f401417590dedf1bd38f71bfbae4 (diff) | |
download | vim-git-163588005da3a240e49416093d0d0251951d60a1.tar.gz |
patch 8.1.1946: memory error when profiling a function without a script IDv8.1.1946
Problem: Memory error when profiling a function without a script ID.
Solution: Check for missing script ID. (closes #4877)
Diffstat (limited to 'src/profiler.c')
-rw-r--r-- | src/profiler.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/profiler.c b/src/profiler.c index 64ee0edec..d7d010f79 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -690,13 +690,16 @@ func_dump_profile(FILE *fd) fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3); else fprintf(fd, "FUNCTION %s()\n", fp->uf_name); - p = home_replace_save(NULL, - get_scriptname(fp->uf_script_ctx.sc_sid)); - if (p != NULL) + if (fp->uf_script_ctx.sc_sid > 0) { - fprintf(fd, " Defined: %s line %ld\n", + p = home_replace_save(NULL, + get_scriptname(fp->uf_script_ctx.sc_sid)); + if (p != NULL) + { + fprintf(fd, " Defined: %s line %ld\n", p, (long)fp->uf_script_ctx.sc_lnum); - vim_free(p); + vim_free(p); + } } if (fp->uf_tm_count == 1) fprintf(fd, "Called 1 time\n"); |