Patch 8.1.1946
Problem:    Memory error when profiling a function without a script ID.
Solution:   Check for missing script ID.  (closes #4877)
Files:      src/testdir/test_profile.vim, src/profiler.c


*** ../vim-8.1.1945/src/testdir/test_profile.vim        2019-08-14 
21:12:00.977833219 +0200
--- src/testdir/test_profile.vim        2019-08-30 18:30:47.077861485 +0200
***************
*** 4,9 ****
--- 4,10 ----
  CheckFeature profile
  
  source shared.vim
+ source screendump.vim
  
  func Test_profile_func()
    let lines =<< trim [CODE]
***************
*** 522,524 ****
--- 523,551 ----
    call delete('Xprofile_file.vim')
    call delete('Xprofile_file.log')
  endfunc
+ 
+ " When typing the function it won't have a script ID, test that this works.
+ func Test_profile_typed_func()
+   CheckScreendump
+ 
+   let lines =<< trim END
+       profile start XprofileTypedFunc
+   END
+   call writefile(lines, 'XtestProfile')
+   let buf = RunVimInTerminal('-S XtestProfile', #{})
+ 
+   call term_sendkeys(buf, ":func DoSomething()\<CR>"
+       \ .. "echo 'hello'\<CR>"
+       \ .. "endfunc\<CR>")
+   call term_sendkeys(buf, ":profile func DoSomething\<CR>")
+   call term_sendkeys(buf, ":call DoSomething()\<CR>")
+   call term_wait(buf, 200)
+   call StopVimInTerminal(buf)
+   let lines = readfile('XprofileTypedFunc')
+   call assert_equal("FUNCTION  DoSomething()", lines[0])
+   call assert_equal("Called 1 time", lines[1])
+ 
+   " clean up
+   call delete('XprofileTypedFunc')
+   call delete('XtestProfile')
+ endfunc
*** ../vim-8.1.1945/src/profiler.c      2019-08-20 20:13:40.330821936 +0200
--- src/profiler.c      2019-08-30 18:32:53.225462146 +0200
***************
*** 690,702 ****
                    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)
                {
!                   fprintf(fd, "    Defined: %s line %ld\n",
                                           p, (long)fp->uf_script_ctx.sc_lnum);
!                   vim_free(p);
                }
                if (fp->uf_tm_count == 1)
                    fprintf(fd, "Called 1 time\n");
--- 690,705 ----
                    fprintf(fd, "FUNCTION  <SNR>%s()\n", fp->uf_name + 3);
                else
                    fprintf(fd, "FUNCTION  %s()\n", fp->uf_name);
!               if (fp->uf_script_ctx.sc_sid > 0)
                {
!                   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);
!                   }
                }
                if (fp->uf_tm_count == 1)
                    fprintf(fd, "Called 1 time\n");
*** ../vim-8.1.1945/src/version.c       2019-08-30 17:34:04.380050974 +0200
--- src/version.c       2019-08-30 18:04:24.980090022 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1946,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
142. You dream about creating the world's greatest web site.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201908301637.x7UGbqbV017277%40masaka.moolenaar.net.

Raspunde prin e-mail lui