diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-05-20 23:33:30 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-05-20 23:33:30 +0200 |
commit | 79fd38228cbd548b5ed0d0e0b67323a807017cd6 (patch) | |
tree | 3d5a35557325e3dc64737d4f8e60155bd5963ff2 /mg.c | |
parent | 9dfa190b44e0f5888ba81337eda267ec8d8a351f (diff) | |
download | perl-79fd38228cbd548b5ed0d0e0b67323a807017cd6.tar.gz |
In Perl_magic_setsig(), don't discard and then recreate the signal name SV.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -1439,14 +1439,23 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg) #ifdef FAKE_DEFAULT_SIGNAL_HANDLERS PL_sig_defaulting[i] = 0; #endif - SvREFCNT_dec(PL_psig_name[i]); to_dec = PL_psig_ptr[i]; if (sv) { PL_psig_ptr[i] = SvREFCNT_inc_simple_NN(sv); SvTEMP_off(sv); /* Make sure it doesn't go away on us */ - PL_psig_name[i] = newSVpvn(s, len); - SvREADONLY_on(PL_psig_name[i]); + + /* Signals don't change name during the program's execution, so once + they're cached in the appropriate slot of PL_psig_name, they can + stay there. + + Ideally we'd find some way of making SVs at (C) compile time, or + at least, doing most of the work. */ + if (!PL_psig_name[i]) { + PL_psig_name[i] = newSVpvn(s, len); + SvREADONLY_on(PL_psig_name[i]); + } } else { + SvREFCNT_dec(PL_psig_name[i]); PL_psig_name[i] = NULL; PL_psig_ptr[i] = NULL; } |