mirror of
https://github.com/SSLMate/certspotter.git
synced 2025-06-27 10:15:33 +02:00
merkletree.Append: fix appending to empty trees
This commit is contained in:
parent
cc98a06bcb
commit
759631f7e6
@ -54,9 +54,11 @@ func (tree *CollapsedTree) Add(hash Hash) {
|
||||
}
|
||||
|
||||
func (tree *CollapsedTree) Append(other *CollapsedTree) error {
|
||||
maxSize := uint64(1) << bits.TrailingZeros64(tree.size)
|
||||
if other.size > maxSize {
|
||||
return fmt.Errorf("tree of size %d is too large to append to a tree of size %d (maximum size is %d)", other.size, tree.size, maxSize)
|
||||
if tree.size > 0 {
|
||||
maxSize := uint64(1) << bits.TrailingZeros64(tree.size)
|
||||
if other.size > maxSize {
|
||||
return fmt.Errorf("tree of size %d is too large to append to a tree of size %d (maximum size is %d)", other.size, tree.size, maxSize)
|
||||
}
|
||||
}
|
||||
|
||||
tree.nodes = append(tree.nodes, other.nodes...)
|
||||
|
Loading…
x
Reference in New Issue
Block a user