Flaw in libtree-redblack-perl

Soules, Craig craig.soules at hp.com
Thu Jul 31 01:03:08 UTC 2008


Hello,

There's a serious flaw in this RedBlack.pm implementation.  Specifically, on line 140:

140:    if ($this->{'cmp'} ? $this->{'cmp'}->($key, $node->key) < 0
141:                   : $key lt $parent->key) {
142:      $parent->left($node);

If you are using a custom compare function, it needs to compare $key to $parent->key, not $node->key.  This causes errors in insertion, which makes the tree completely useless.

Hopefully someone can fix this in a future release!

Thanks,
Craig



More information about the pkg-perl-maintainers mailing list