network: fix SIGSEGV on unknown message acceptance
For example, at the moment our node can't handle `consensus` message, so when it received it before the patch it just crashed because of uninitialized `p`.
This commit is contained in:
parent
4b4bac675b
commit
5a0f08f2c0
1 changed files with 3 additions and 0 deletions
|
@ -3,6 +3,7 @@ package network
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/CityOfZion/neo-go/config"
|
"github.com/CityOfZion/neo-go/config"
|
||||||
"github.com/CityOfZion/neo-go/pkg/core"
|
"github.com/CityOfZion/neo-go/pkg/core"
|
||||||
|
@ -193,6 +194,8 @@ func (m *Message) decodePayload(br *io.BinReader) error {
|
||||||
p = &transaction.Transaction{}
|
p = &transaction.Transaction{}
|
||||||
case CMDMerkleBlock:
|
case CMDMerkleBlock:
|
||||||
p = &payload.MerkleBlock{}
|
p = &payload.MerkleBlock{}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("can't decode command %s", cmdByteArrayToString(m.Command))
|
||||||
}
|
}
|
||||||
p.DecodeBinary(r)
|
p.DecodeBinary(r)
|
||||||
if r.Err != nil {
|
if r.Err != nil {
|
||||||
|
|
Loading…
Reference in a new issue