common: fix BitArray.Update to avoid nil dereference

Update previously only checked that the receiver was
non-nil but didn't check that the input parameter to update
"o" was non-nil causing a nil dereference in cases such as
https://github.com/tendermint/tendermint/blob/fe632ea32a89c3d9804bbd6e3ce9391b1d5a0993/consensus/reactor.go#L306

Fixes https://github.com/tendermint/tendermint/issues/1169
This commit is contained in:
Emmanuel Odeke
2018-01-28 10:39:42 -07:00
parent fa8c374aff
commit 84afef20f5
2 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -306,7 +306,7 @@ func (bA *BitArray) Bytes() []byte {
// so if necessary, caller must copy or lock o prior to calling Update.
// If bA is nil, does nothing.
func (bA *BitArray) Update(o *BitArray) {
if bA == nil {
if bA == nil || o == nil {
return
}
bA.mtx.Lock()