Freeing the UTCP instance of a node would result in meshlink_send() being
called on a node that was already partially freed.
static ssize_t channel_send(struct utcp *utcp, const void *data, size_t len) {
node_t *n = utcp->priv;
+
+ if(n->status.destroyed) {
+ return -1;
+ }
+
meshlink_handle_t *mesh = n->mesh;
return meshlink_send(mesh, (meshlink_node_t *)n, data, len) ? (ssize_t)len : -1;
}
void free_node(node_t *n) {
n->status.destroyed = true;
+ utcp_exit(n->utcp);
+
if(n->edge_tree) {
free_edge_tree(n->edge_tree);
}
free(n->name);
- utcp_exit(n->utcp);
-
free(n);
}