diff options
author | Felix Lange <fjl@twurst.com> | 2016-09-29 22:51:32 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-09-30 04:53:59 +0800 |
commit | c3a77d626831b4ffe37ed4f8640e67e70ad5b220 (patch) | |
tree | a35c0a61ab1fd8f7098445405e45532eb6d13895 /trie/trie.go | |
parent | ba8c4c6b1a3ee6740420ac264df1dbceaba4b555 (diff) | |
download | go-tangerine-c3a77d626831b4ffe37ed4f8640e67e70ad5b220.tar go-tangerine-c3a77d626831b4ffe37ed4f8640e67e70ad5b220.tar.gz go-tangerine-c3a77d626831b4ffe37ed4f8640e67e70ad5b220.tar.bz2 go-tangerine-c3a77d626831b4ffe37ed4f8640e67e70ad5b220.tar.lz go-tangerine-c3a77d626831b4ffe37ed4f8640e67e70ad5b220.tar.xz go-tangerine-c3a77d626831b4ffe37ed4f8640e67e70ad5b220.tar.zst go-tangerine-c3a77d626831b4ffe37ed4f8640e67e70ad5b220.zip |
trie: fix delete bug for values contained in fullNode
Delete crashed if a fullNode contained a valueNode directly. This bug is
very unlikely to occur with SecureTrie, but can happen with regular
tries. This commit also introduces a randomised test which triggers all
trie operations, which should prevent such bugs in the future.
Credit for finding this bug goes to Github user @rjl493456442.
Diffstat (limited to 'trie/trie.go')
-rw-r--r-- | trie/trie.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/trie/trie.go b/trie/trie.go index 55481f4f7..55598af98 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -377,6 +377,9 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) { // n still contains at least two values and cannot be reduced. return true, n, nil + case valueNode: + return true, nil, nil + case nil: return false, nil, nil |