From d56327b887684d5a6b99a348bbb38b87c24848c2 Mon Sep 17 00:00:00 2001 From: Oren Date: Mon, 27 Mar 2017 14:11:45 +0300 Subject: [PATCH] check data len for 0 --- swarm/storage/binarymerkle.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swarm/storage/binarymerkle.go b/swarm/storage/binarymerkle.go index 12e0e96ea7..c33fe3d1a9 100644 --- a/swarm/storage/binarymerkle.go +++ b/swarm/storage/binarymerkle.go @@ -178,6 +178,9 @@ func GetHeight(count uint64) int { // Count - Numers of leafs at the BMT // 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 leafcount := len(data) / segmentsize if len(data)%segmentsize != 0 {