aboutsummaryrefslogtreecommitdiff
path: root/src/sp
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-05-27 19:21:17 -0700
committerGarrett D'Amore <garrett@damore.org>2024-05-30 07:28:48 -0700
commit6a2a8aa7806953d221f8818982a30cdcea47a82b (patch)
tree00010e6d8abf873acac402416596fe862a07cb35 /src/sp
parent76707668e3593094e1c5e675691b11230a565a1e (diff)
downloadnng-6a2a8aa7806953d221f8818982a30cdcea47a82b.tar.gz
nng-6a2a8aa7806953d221f8818982a30cdcea47a82b.tar.bz2
nng-6a2a8aa7806953d221f8818982a30cdcea47a82b.zip
Free SP protocol streams before discarding aio objects.
This seems to alleviate the use after free crashes, although it does not seem like it should. Current theory is that this closes the handle ensuring that it is unregistered from the I/O subsystem, thus preventing callbacks from firing and referring to objects that have been freed.
Diffstat (limited to 'src/sp')
-rw-r--r--src/sp/transport/ipc/ipc.c2
-rw-r--r--src/sp/transport/tcp/tcp.c2
-rw-r--r--src/sp/transport/tls/tls.c2
-rw-r--r--src/sp/transport/ws/websocket.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/sp/transport/ipc/ipc.c b/src/sp/transport/ipc/ipc.c
index 18972bab..a9aa0113 100644
--- a/src/sp/transport/ipc/ipc.c
+++ b/src/sp/transport/ipc/ipc.c
@@ -150,10 +150,10 @@ ipc_pipe_fini(void *arg)
}
nni_mtx_unlock(&ep->mtx);
}
+ nng_stream_free(p->conn);
nni_aio_fini(&p->rx_aio);
nni_aio_fini(&p->tx_aio);
nni_aio_fini(&p->neg_aio);
- nng_stream_free(p->conn);
if (p->rx_msg) {
nni_msg_free(p->rx_msg);
}
diff --git a/src/sp/transport/tcp/tcp.c b/src/sp/transport/tcp/tcp.c
index 95881dd9..be2e0345 100644
--- a/src/sp/transport/tcp/tcp.c
+++ b/src/sp/transport/tcp/tcp.c
@@ -153,10 +153,10 @@ tcptran_pipe_fini(void *arg)
nni_mtx_unlock(&ep->mtx);
}
+ nng_stream_free(p->conn);
nni_aio_free(p->rxaio);
nni_aio_free(p->txaio);
nni_aio_free(p->negoaio);
- nng_stream_free(p->conn);
nni_msg_free(p->rxmsg);
nni_mtx_fini(&p->mtx);
NNI_FREE_STRUCT(p);
diff --git a/src/sp/transport/tls/tls.c b/src/sp/transport/tls/tls.c
index 631d74d7..240b1ed9 100644
--- a/src/sp/transport/tls/tls.c
+++ b/src/sp/transport/tls/tls.c
@@ -153,10 +153,10 @@ tlstran_pipe_fini(void *arg)
}
nni_mtx_unlock(&ep->mtx);
}
+ nng_stream_free(p->tls);
nni_aio_free(p->rxaio);
nni_aio_free(p->txaio);
nni_aio_free(p->negoaio);
- nng_stream_free(p->tls);
nni_msg_free(p->rxmsg);
NNI_FREE_STRUCT(p);
}
diff --git a/src/sp/transport/ws/websocket.c b/src/sp/transport/ws/websocket.c
index 69509e84..3def08d3 100644
--- a/src/sp/transport/ws/websocket.c
+++ b/src/sp/transport/ws/websocket.c
@@ -200,10 +200,10 @@ wstran_pipe_fini(void *arg)
{
ws_pipe *p = arg;
+ nng_stream_free(p->ws);
nni_aio_free(p->rxaio);
nni_aio_free(p->txaio);
- nng_stream_free(p->ws);
nni_mtx_fini(&p->mtx);
NNI_FREE_STRUCT(p);
}