diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-01-08 18:14:03 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-01-08 23:13:36 -0800 |
commit | 55b5114f4ff694ab871173b736aa2d48bb095684 (patch) | |
tree | 8258cd178c80da1a45ea12f0e511f1668822e798 /perl.h | |
parent | bbff98dc509eb269f4500b2698d1ab918152f9d2 (diff) | |
download | perl-55b5114f4ff694ab871173b736aa2d48bb095684.tar.gz |
[perl #92254, #92256] Fix SAVE_DEFSV to do refcounting
The current definition of SAVE_DEFSV doesn’t take reference count-
ing into account. Every instance of it in the perl core is buggy
as a result.
Most are also followed by DEFSV_set, which is likewise buggy.
This commit implements SAVE_DEFSV in terms of save_gp and
SAVEGENERICSV if PERL_CORE is defined. save_gp and SAVEGENERICSV are
what local(*_) = \$foo uses. Changing the definition for XS code is
probably too risky this close to 5.16. It should probably be changed
later, though.
DEFSV_set is now changed to do reference counting too.
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1355,11 +1355,20 @@ EXTERN_C char *crypt(const char *, const char *); #ifdef PERL_CORE # define DEFSV (0 + GvSVn(PL_defgv)) +# define DEFSV_set(sv) \ + (SvREFCNT_dec(GvSV(PL_defgv)), GvSV(PL_defgv) = SvREFCNT_inc(sv)) +# define SAVE_DEFSV \ + ( \ + save_gp(PL_defgv, 0), \ + GvINTRO_off(PL_defgv), \ + SAVEGENERICSV(GvSV(PL_defgv)), \ + GvSV(PL_defgv) = NULL \ + ) #else # define DEFSV GvSVn(PL_defgv) +# define DEFSV_set(sv) (GvSV(PL_defgv) = (sv)) +# define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif -#define DEFSV_set(sv) (GvSV(PL_defgv) = (sv)) -#define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #define ERRHV GvHV(PL_errgv) /* XXX unused, here for compatibility */ |