mirror of https://github.com/vacp2p/nim-libp2p.git
con't crash on nil ptr
This commit is contained in:
parent
7cb6c81159
commit
3c4c10d871
|
@ -75,11 +75,13 @@ method handle*(m: Mplex) {.async, gcsafe.} =
|
||||||
msgType = msgType,
|
msgType = msgType,
|
||||||
data = data.shortLog,
|
data = data.shortLog,
|
||||||
oid = m.oid
|
oid = m.oid
|
||||||
|
|
||||||
let initiator = bool(ord(msgType) and 1)
|
let initiator = bool(ord(msgType) and 1)
|
||||||
var channel: LPChannel
|
var channel: LPChannel
|
||||||
if MessageType(msgType) != MessageType.New:
|
if MessageType(msgType) != MessageType.New:
|
||||||
let channels = m.getChannelList(initiator)
|
let channels = m.getChannelList(initiator)
|
||||||
if id notin channels:
|
if id notin channels:
|
||||||
|
|
||||||
trace "Channel not found, skipping", id = id,
|
trace "Channel not found, skipping", id = id,
|
||||||
initiator = initiator,
|
initiator = initiator,
|
||||||
msg = msgType,
|
msg = msgType,
|
||||||
|
@ -98,11 +100,9 @@ method handle*(m: Mplex) {.async, gcsafe.} =
|
||||||
of MessageType.New:
|
of MessageType.New:
|
||||||
let name = string.fromBytes(data)
|
let name = string.fromBytes(data)
|
||||||
channel = await m.newStreamInternal(false, id, name)
|
channel = await m.newStreamInternal(false, id, name)
|
||||||
logScope:
|
|
||||||
name = channel.name
|
|
||||||
chann_iod = channel.oid
|
|
||||||
|
|
||||||
trace "created channel"
|
trace "created channel", name = channel.name,
|
||||||
|
chann_iod = channel.oid
|
||||||
|
|
||||||
if not isNil(m.streamHandler):
|
if not isNil(m.streamHandler):
|
||||||
let stream = newConnection(channel)
|
let stream = newConnection(channel)
|
||||||
|
|
Loading…
Reference in New Issue