From 6639b3534e2bcf41644cc1362119097cdcfaddc3 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Tue, 8 May 2012 08:58:14 -0700 Subject: [PATCH] Close all input files in Shorewall::Config::cleanup() Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Config.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 7d26f7bdd..e230d5711 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -876,6 +876,30 @@ sub cleanup() { close $script, $script = undef if $script; close $perlscript, $perlscript = undef if $perlscript; close $log, $log = undef if $log; + + if ( $currentfile ) { + # + # We have a current input file; close it + # + close $currentfile; + # + # Unwind the current include stack + # + for ( my $i = @includestack - 1; $i >= 0; $i-- ) { + my $info = $includestack[$i]; + close $info->[0]; + } + # + # Now unwind the open stack; each element is an include stack + # + for ( my $i = @openstack - 1; $i >= 0; $i-- ) { + my $istack = $openstack[$i]; + for ( my $j = ( @$istack - 1 ); $j >= 0; $j-- ) { + my $info = $istack->[$j]; + close $info->[0]; + } + } + } # # Unlink temporary files #