diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-11-29 19:02:05 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-11-29 19:02:05 +0000 |
commit | dfd167e94af611f6248e804cb228b35ca4123bd6 (patch) | |
tree | 69a15032aa8f927649745d4b8053c03d46edbe27 /perl.h | |
parent | f5fa9033b8c1fdcbd7710850b3b0380d6b937853 (diff) | |
download | perl-dfd167e94af611f6248e804cb228b35ca4123bd6.tar.gz |
Handle $@ being assigned a read-only value (without error or busting the stack).
Discovered whilst investigating RT #70862.
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -1311,6 +1311,24 @@ EXTERN_C char *crypt(const char *, const char *); #endif #define ERRSV GvSVn(PL_errgv) + +#define CLEAR_ERRSV() STMT_START { \ + if (!GvSV(PL_errgv)) { \ + sv_setpvs(GvSV(gv_add_by_type(PL_errgv, SVt_PV)), ""); \ + } else if (SvREADONLY(GvSV(PL_errgv))) { \ + SvREFCNT_dec(GvSV(PL_errgv)); \ + GvSV(PL_errgv) = newSVpvs(""); \ + } else { \ + SV *const errsv = GvSV(PL_errgv); \ + sv_setpvs(errsv, ""); \ + if (SvMAGICAL(errsv)) { \ + mg_free(errsv); \ + } \ + SvPOK_only(errsv); \ + } \ + } STMT_END + + #ifdef PERL_CORE # define DEFSV (0 + GvSVn(PL_defgv)) #else @@ -6129,8 +6147,6 @@ extern void moncontrol(int); #endif /* Include guard */ -#define CLEAR_ERRSV() STMT_START { sv_setpvn(ERRSV,"",0); if (SvMAGICAL(ERRSV)) { mg_free(ERRSV); } SvPOK_only(ERRSV); } STMT_END - /* * Local variables: * c-indentation-style: bsd |