0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 7.4.1746

Problem:    Memory leak in Perl.
Solution:   Decrement the reference count.  Add a test. (Damien)
This commit is contained in:
Bram Moolenaar
2016-04-15 21:16:11 +02:00
parent 5d98c9d932
commit 95509e18f8
3 changed files with 26 additions and 5 deletions

View File

@@ -844,6 +844,7 @@ I32 cur_val(IV iv, SV *sv)
else else
rv = newBUFrv(newSV(0), curbuf); rv = newBUFrv(newSV(0), curbuf);
sv_setsv(sv, rv); sv_setsv(sv, rv);
SvREFCNT_dec(SvRV(rv));
return 0; return 0;
} }
#endif /* !PROTO */ #endif /* !PROTO */

View File

@@ -34,7 +34,7 @@ fu <SID>catch_peval(expr)
endtry endtry
call assert_true(0, 'no exception for `perleval("'.a:expr.'")`') call assert_true(0, 'no exception for `perleval("'.a:expr.'")`')
return '' return ''
endf endfunc
function Test_perleval() function Test_perleval()
call assert_false(perleval('undef')) call assert_false(perleval('undef'))
@@ -73,7 +73,7 @@ function Test_perleval()
call assert_equal('*VIM', perleval('"*VIM"')) call assert_equal('*VIM', perleval('"*VIM"'))
call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)') call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)')
endf endfunc
function Test_perldo() function Test_perldo()
sp __TEST__ sp __TEST__
@@ -82,7 +82,7 @@ function Test_perldo()
1 1
call assert_false(search('\Cperl')) call assert_false(search('\Cperl'))
bw! bw!
endf endfunc
function Test_VIM_package() function Test_VIM_package()
perl VIM::DoCommand('let l:var = "foo"') perl VIM::DoCommand('let l:var = "foo"')
@@ -91,7 +91,7 @@ function Test_VIM_package()
set noet set noet
perl VIM::SetOption('et') perl VIM::SetOption('et')
call assert_true(&et) call assert_true(&et)
endf endfunc
function Test_stdio() function Test_stdio()
redir =>l:out redir =>l:out
@@ -102,4 +102,22 @@ function Test_stdio()
EOF EOF
redir END redir END
call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n")) 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

View File

@@ -748,6 +748,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1746,
/**/ /**/
1745, 1745,
/**/ /**/