go-hamt-ipld icon indicating copy to clipboard operation
go-hamt-ipld copied to clipboard

Internal HAMT error could cause panic

Open ZenGround0 opened this issue 6 years ago • 1 comments

Is it ok that an inconsistently setup HAMT will cause a panic? The pointer returned here is dereferenced without nil checking.

An inconsistent setup is actually checked earlier within the method returning the pointer here but it silently passes nil just deferring the panic to the caller.

It seems like this method should return an error or else own the decision to panic when in a bad state and not check the index against the length of the Pointers array.

ZenGround0 avatar Jun 05 '19 19:06 ZenGround0

A year has passed and the link has drifted out of date, but @rvagg made the same observation and recommends adding an error in comment: https://github.com/filecoin-project/go-hamt-ipld/blob/master/hamt.go#L745

ZenGround0 avatar Nov 25 '20 20:11 ZenGround0