From: Nicholas Clark Date: Wed, 20 May 2009 21:33:30 +0000 (+0200) Subject: In Perl_magic_setsig(), don't discard and then recreate the signal name SV. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=79fd38228cbd548b5ed0d0e0b67323a807017cd6;p=p5sagit%2Fp5-mst-13.2.git In Perl_magic_setsig(), don't discard and then recreate the signal name SV. --- diff --git a/mg.c b/mg.c index 819e105..1bc5bf7 100644 --- a/mg.c +++ b/mg.c @@ -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; }