Language: Go
Label: safe
CWE: CWE-400 \u2014 Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.

Code:
func NewUnixFSHAMTShard(ctx context.Context, substrate dagpb.PBNode, data data.UnixFSData, lsys *ipld.LinkSystem) (ipld.Node, error) {
	if err := validateHAMTData(data); err != nil {
		return nil, err
	}
	shardCache := make(map[ipld.Link]*_UnixFSHAMTShard, substrate.FieldLinks().Length())
	bf, err := bitField(data)
	if err != nil {
		return nil, err
	}
	return &_UnixFSHAMTShard{
		ctx:          ctx,
		_substrate:   substrate,
		data:         data,
		lsys:         lsys,
		shardCache:   shardCache,
		bitfield:     bf,
		cachedLength: -1,
	}, nil
}