]> granicus.if.org Git - vim/commitdiff
patch 7.4.1746 v7.4.1746
authorBram Moolenaar <Bram@vim.org>
Fri, 15 Apr 2016 19:16:11 +0000 (21:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 15 Apr 2016 19:16:11 +0000 (21:16 +0200)
Problem:    Memory leak in Perl.
Solution:   Decrement the reference count.  Add a test. (Damien)

src/if_perl.xs
src/testdir/test_perl.vim
src/version.c

index b091bf7cab7977c1f77b57134258f81e45d65187..23246a57b11888164c07726fd7c6a7f744ceb73c 100644 (file)
@@ -844,6 +844,7 @@ I32 cur_val(IV iv, SV *sv)
     else
        rv = newBUFrv(newSV(0), curbuf);
     sv_setsv(sv, rv);
+    SvREFCNT_dec(SvRV(rv));
     return 0;
 }
 #endif /* !PROTO */
index b523805a8998d63d031cdb3e76dedaeb2d345e6c..da47ab153c3cc74ea77052675e1abf188aeca9bb 100644 (file)
@@ -34,7 +34,7 @@ fu <SID>catch_peval(expr)
   endtry
   call assert_true(0, 'no exception for `perleval("'.a:expr.'")`')
   return ''
-endf
+endfunc
 
 function Test_perleval()
   call assert_false(perleval('undef'))
@@ -73,7 +73,7 @@ function Test_perleval()
 
   call assert_equal('*VIM', perleval('"*VIM"'))
   call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)')
-endf
+endfunc
 
 function Test_perldo()
   sp __TEST__
@@ -82,7 +82,7 @@ function Test_perldo()
   1
   call assert_false(search('\Cperl'))
   bw!
-endf
+endfunc
 
 function Test_VIM_package()
   perl VIM::DoCommand('let l:var = "foo"')
@@ -91,7 +91,7 @@ function Test_VIM_package()
   set noet
   perl VIM::SetOption('et')
   call assert_true(&et)
-endf
+endfunc
 
 function Test_stdio()
   redir =>l:out
@@ -102,4 +102,22 @@ function Test_stdio()
 EOF
   redir END
   call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n"))
-endf
+endfunc
+
+function Test_SvREFCNT()
+  new t
+  perl <<--perl
+  my ($b, $w);
+  $b = $curbuf for 0 .. 10;
+  $w = $curwin for 0 .. 10;
+  VIM::DoCommand('bw! t');
+  if (exists &Internals::SvREFCNT) {
+      my $cb = Internals::SvREFCNT($$b);
+      my $cw = Internals::SvREFCNT($$w);
+      VIM::Eval("assert_equal(2, $cb)");
+      VIM::Eval("assert_equal(2, $cw)");
+  }
+  VIM::Eval("assert_false($$b)");
+  VIM::Eval("assert_false($$w)");
+--perl
+endfunc
index bfb64e6dee6b812939d7b9e3e5a71c718bbd6fe3..74e5f92359a72edd1435e24a8c2494d14313fae0 100644 (file)
@@ -748,6 +748,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1746,
 /**/
     1745,
 /**/