diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-08-02 21:46:51 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-08-02 21:46:51 +0200 |
commit | 41c363a3154dd1caeb431fa54748ad48ef6d3bd1 (patch) | |
tree | 91c64ec29455162f4f9dd54cc1ecac0a929501c3 /src/if_perl.xs | |
parent | ded27a1febda3db7447958b60a7d791af514d124 (diff) | |
download | vim-git-41c363a3154dd1caeb431fa54748ad48ef6d3bd1.tar.gz |
patch 8.1.0234: incorrect reference counting in Perl interfacev8.1.0234
Problem: Incorrect reference counting in Perl interface.
Solution: Call SvREFCNT_inc more often, add a test. (Damien)
Diffstat (limited to 'src/if_perl.xs')
-rw-r--r-- | src/if_perl.xs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/if_perl.xs b/src/if_perl.xs index bc15efa94..9fd219691 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -831,8 +831,7 @@ newWINrv(SV *rv, win_T *ptr) ptr->w_perl_private = newSV(0); sv_setiv(ptr->w_perl_private, PTR2IV(ptr)); } - else - SvREFCNT_inc_void_NN(ptr->w_perl_private); + SvREFCNT_inc_void_NN(ptr->w_perl_private); SvRV(rv) = ptr->w_perl_private; SvROK_on(rv); return sv_bless(rv, gv_stashpv("VIWIN", TRUE)); @@ -847,8 +846,7 @@ newBUFrv(SV *rv, buf_T *ptr) ptr->b_perl_private = newSV(0); sv_setiv(ptr->b_perl_private, PTR2IV(ptr)); } - else - SvREFCNT_inc_void_NN(ptr->b_perl_private); + SvREFCNT_inc_void_NN(ptr->b_perl_private); SvRV(rv) = ptr->b_perl_private; SvROK_on(rv); return sv_bless(rv, gv_stashpv("VIBUF", TRUE)); @@ -918,12 +916,13 @@ I32 cur_val(IV iv, SV *sv) else rv = newBUFrv(newSV(0), curbuf); - if (SvRV(sv) == SvRV(rv)) - SvREFCNT_dec(SvRV(rv)); - else // XXX: Not sure if the `else` condition are right - // Test_SvREFCNT() pass in all case. + if (SvRV(sv) != SvRV(rv)) + // XXX: This magic variable is a bit confusing... + // Is curently refcounted ? sv_setsv(sv, rv); + SvREFCNT_dec(rv); + return 0; } #endif /* !PROTO */ |