You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2008/08/11 18:48:23 UTC
svn commit: r684810 - in /spamassassin/trunk/lib/Mail/SpamAssassin:
Message.pm Util/ScopedTimer.pm
Author: mmartinec
Date: Mon Aug 11 09:48:21 2008
New Revision: 684810
URL: http://svn.apache.org/viewvc?rev=684810&view=rev
Log:
Best practices: localized $@ and $! in DESTROY methods to prevent
potential calls to eval and calls to system routines in code executed
from a DESTROY method from clobbering global variables $@ and $!,
possibly affecting further error processing. Executing eval {} within
a DESTROY explains mysterious sightings when some outer eval captured
an event but $@ was empty.
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Util/ScopedTimer.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm?rev=684810&r1=684809&r2=684810&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm Mon Aug 11 09:48:21 2008
@@ -573,6 +573,9 @@
# temporary files are deleted even if the finish() method is omitted
sub DESTROY {
my $self = shift;
+ # best practices: prevent potential calls to eval and to system routines
+ # in code of a DESTROY method from clobbering global variables $@ and $!
+ local($@,$!); # keep outer error handling unaffected by DESTROY
if ($self->{'tmpfiles'}) {
unlink @{$self->{'tmpfiles'}};
}
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util/ScopedTimer.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util/ScopedTimer.pm?rev=684810&r1=684809&r2=684810&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util/ScopedTimer.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util/ScopedTimer.pm Mon Aug 11 09:48:21 2008
@@ -39,6 +39,9 @@
# OO hack: when the object goes out of scope, the timer ends. neat!
sub DESTROY {
my $self = shift;
+ # best practices: prevent potential calls to eval and to system routines
+ # in code of a DESTROY method from clobbering global variables $@ and $!
+ local($@,$!); # keep outer error handling unaffected by DESTROY
$self->{main}->timer_end($self->{timer});
}