comparison src/profiler.c @ 17899:48fd0712dad8 v8.1.1946

patch 8.1.1946: memory error when profiling a function without a script ID Commit: https://github.com/vim/vim/commit/163588005da3a240e49416093d0d0251951d60a1 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 30 18:37:26 2019 +0200 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 https://github.com/vim/vim/issues/4877)
author Bram Moolenaar <Bram@vim.org>
date Fri, 30 Aug 2019 18:45:03 +0200
parents 0f7ae8010787
children ed222e264905
comparison
equal deleted inserted replaced
17898:a7551a81103d 17899:48fd0712dad8
688 688
689 if (fp->uf_name[0] == K_SPECIAL) 689 if (fp->uf_name[0] == K_SPECIAL)
690 fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3); 690 fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3);
691 else 691 else
692 fprintf(fd, "FUNCTION %s()\n", fp->uf_name); 692 fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
693 p = home_replace_save(NULL, 693 if (fp->uf_script_ctx.sc_sid > 0)
694 {
695 p = home_replace_save(NULL,
694 get_scriptname(fp->uf_script_ctx.sc_sid)); 696 get_scriptname(fp->uf_script_ctx.sc_sid));
695 if (p != NULL) 697 if (p != NULL)
696 { 698 {
697 fprintf(fd, " Defined: %s line %ld\n", 699 fprintf(fd, " Defined: %s line %ld\n",
698 p, (long)fp->uf_script_ctx.sc_lnum); 700 p, (long)fp->uf_script_ctx.sc_lnum);
699 vim_free(p); 701 vim_free(p);
702 }
700 } 703 }
701 if (fp->uf_tm_count == 1) 704 if (fp->uf_tm_count == 1)
702 fprintf(fd, "Called 1 time\n"); 705 fprintf(fd, "Called 1 time\n");
703 else 706 else
704 fprintf(fd, "Called %d times\n", fp->uf_tm_count); 707 fprintf(fd, "Called %d times\n", fp->uf_tm_count);