Subject: | bug in SVG::DOM v.2.44 |
Date: | Sat, 22 Aug 2009 14:20:37 +0200 |
To: | bug-SVG [...] rt.cpan.org |
From: | Lukas Pietsch <lukas.pietsch [...] freenet.de> |
Bug report for SVG::DOM v.2.44:
The function "findChildIndex" (SVG::DOM, line 520) does not initialise
its counting variable "$index" properly before entering the loop. It
will return undef rather than zero if called with a $refChild that is in
fact its first child. This leads to errors/warnings in other functions
that call findChildIndex, such as removeChild:
"Use of uninitialized value in numeric lt (<)
at /usr/local/share/perl/5.8.8/SVG/DOM.pm line 475.
Use of uninitialized value in splice
at /usr/local/share/perl/5.8.8/SVG/DOM.pm line 549."
The following fix would seem to work:
sub findChildIndex
{
my ($self, $refChild) = @_;
my $index = 0;
foreach my $child (@{$self->{-childs}}) {
return $index if ($child eq $refChild);
$index++;
}
return -1;
}
Best regards,
L. Pietsch