Fix SIGSEGV while consuming errors more then once. (#114)

This commit is contained in:
Eugene Kabanov 2020-08-05 00:23:43 +03:00 committed by GitHub
parent f5634f499d
commit 73de13ca7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -817,6 +817,7 @@ proc peekMessage*(transp: DatagramTransport, msg: var seq[byte],
msglen: var int) =
## Get access to internal message buffer and length of incoming datagram.
if ReadError in transp.state:
transp.state.excl(ReadError)
raise transp.getError()
shallowCopy(msg, transp.buffer)
msglen = transp.buflen
@ -824,6 +825,7 @@ proc peekMessage*(transp: DatagramTransport, msg: var seq[byte],
proc getMessage*(transp: DatagramTransport): seq[byte] =
## Copy data from internal message buffer and return result.
if ReadError in transp.state:
transp.state.excl(ReadError)
raise transp.getError()
if transp.buflen > 0:
result = newSeq[byte](transp.buflen)