From: Manuel Mausz Date: Thu, 22 Feb 2024 09:41:00 +0000 (+0100) Subject: Sorting tree: Check if the key exists. Do not care about its value. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F247%2Fhead;p=thirdparty%2FAWStats.git Sorting tree: Check if the key exists. Do not care about its value. Fixes eldy/AWStats#246 --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 649fbd78..879936a5 100755 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -8472,7 +8472,7 @@ sub AddInTree { } return; } - if ( $val{$keyval} ) { # Val is already in tree + if ( exists($val{$keyval}) ) { # Val is already in tree if ($Debug) { debug( " val is already in tree", 4 ); } $egal{$keytoadd} = $val{$keyval}; $val{$keyval} = $keytoadd; @@ -8519,7 +8519,7 @@ sub AddInTree { while ( $nextval{$valcursor} && ( $nextval{$valcursor} < $keyval ) ) { $valcursor = $nextval{$valcursor}; } - if ( $nextval{$valcursor} ) + if ( exists($nextval{$valcursor}) ) { # keyval is between valcursor and nextval{valcursor} $nextval{$keyval} = $nextval{$valcursor}; } @@ -8547,7 +8547,7 @@ sub Removelowerval { if ($Debug) { debug( " remove for lowerval=$lowerval: key=$keytoremove", 4 ); } - if ( $egal{$keytoremove} ) { + if ( exists($egal{$keytoremove}) ) { $val{$lowerval} = $egal{$keytoremove}; delete $egal{$keytoremove}; }