2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-28 05:01:57 +00:00

Avoid endless recursion in commandlist if the $hash contains a pointer to

itself.


git-svn-id: https://svn.fhem.de/fhem/trunk@3070 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-04-13 10:39:20 +00:00
parent c5075e1245
commit d7cfbea392

View File

@ -1510,10 +1510,12 @@ PrintHash($$)
{ {
my ($h, $lev) = @_; my ($h, $lev) = @_;
my $si = AttrVal("global", "showInternalValues", 0); my $si = AttrVal("global", "showInternalValues", 0);
return "" if($h->{".visited"});
$h->{".visited"} = 1;
my ($str,$sstr) = ("",""); my ($str,$sstr) = ("","");
foreach my $c (sort keys %{$h}) { foreach my $c (sort keys %{$h}) {
next if(!$si && $c =~ m/^\./); next if(!$si && $c =~ m/^\./ || $c eq ".visited");
if(ref($h->{$c})) { if(ref($h->{$c})) {
if(ref($h->{$c}) eq "HASH") { if(ref($h->{$c}) eq "HASH") {
if(defined($h->{$c}{TIME}) && defined($h->{$c}{VAL})) { if(defined($h->{$c}{TIME}) && defined($h->{$c}{VAL})) {
@ -1538,6 +1540,7 @@ PrintHash($$)
$str .= sprintf("%*s %-10s %s\n", $lev," ",$c, defined($v) ? $v : ""); $str .= sprintf("%*s %-10s %s\n", $lev," ",$c, defined($v) ? $v : "");
} }
} }
delete $h->{".visited"};
return $str . $sstr; return $str . $sstr;
} }