Fix: Connection should be passed by reference to avoid double free

This commit is contained in:
Mark Spanbroek 2020-10-13 15:36:00 +02:00 committed by markspanbroek
parent 7dca48fffb
commit dece29fdfa
1 changed files with 6 additions and 4 deletions

View File

@ -1,11 +1,13 @@
import ngtcp2
import path
type Connection* = object
conn*: ptr ngtcp2_conn
path*: Path
type
Connection* = ref ConnectionObj
ConnectionObj = object
conn*: ptr ngtcp2_conn
path*: Path
proc `=destroy`*(connection: var Connection) =
proc `=destroy`*(connection: var ConnectionObj) =
if connection.conn != nil:
ngtcp2_conn_del(connection.conn)
connection.conn = nil