check data len for 0

This commit is contained in:
Oren 2017-03-27 14:11:45 +03:00
parent aacecda1a4
commit d56327b887

View file

@ -178,6 +178,9 @@ func GetHeight(count uint64) int {
// Count - Numers of leafs at the BMT // Count - Numers of leafs at the BMT
// error - // error -
func BuildBMT(h Hasher, data []byte, segmentsize int) (bmt *BTree, roor *Root, count int, err error) { func BuildBMT(h Hasher, data []byte, segmentsize int) (bmt *BTree, roor *Root, count int, err error) {
if len(data) == 0 {
return nil, nil, 0, errors.New("data length is 0 ")
}
hashFunc = h hashFunc = h
leafcount := len(data) / segmentsize leafcount := len(data) / segmentsize
if len(data)%segmentsize != 0 { if len(data)%segmentsize != 0 {