Adjust reference counts when splicing in short chain

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-08-14 08:34:51 -07:00
parent fdc45a990d
commit 8487c78a0a

View File

@ -3010,9 +3010,16 @@ sub optimize_level4( $$ ) {
if ( $_->{simple} && ( $_->{target} || '' ) eq $name ) { if ( $_->{simple} && ( $_->{target} || '' ) eq $name ) {
trace( $sourceref, 'D', $rulenum + 1, $_ ) if $debug; trace( $sourceref, 'D', $rulenum + 1, $_ ) if $debug;
splice @$rulesref, $rulenum, 1, @{$chainref->{rules}}; splice @$rulesref, $rulenum, 1, @{$chainref->{rules}};
if ( $debug ) { while ( my $ruleref = shift @{$chainref->{rules}} ) {
while ( my $ruleref = shift @{$chainref->{rules}} ) { trace ( $sourceref, 'I', $rulenum++, $ruleref ) if $debug;
trace ( $sourceref, 'I', $rulenum++, $ruleref ); my $target = $ruleref->{target};
if ( $target && ( my $targetref = $tableref->{$target} ) ) {
#
# The rule target is a chain
#
add_reference( $chainref, $targetref );
delete_reference( $sourceref, $targetref );
} }
} }
@ -3021,7 +3028,6 @@ sub optimize_level4( $$ ) {
last; last;
} }
$rulenum++; $rulenum++;
} }
} }
} }