Commit e4a4b6f2 authored by Alexander Alashkin's avatar Alexander Alashkin Committed by Cesanta Bot

Fix coredump in mg_tun_destroy_client

PUBLISHED_FROM=56ff5afe805e4680e02183a8c3887ea60ee5ebfe
parent 0ceee1dc
......@@ -11342,10 +11342,24 @@ static struct mg_tun_client *mg_tun_create_client(struct mg_mgr *mgr,
}
void mg_tun_destroy_client(struct mg_tun_client *client) {
/*
* NOTE:
* `client` is NULL in case of OOM
* `client->disp` is NULL if connection failed
* `client->iface is NULL is `mg_find_iface` failed
*/
if (client != NULL && client->disp != NULL) {
/* the dispatcher connection handler will in turn close all tunnels */
client->disp->flags |= MG_F_CLOSE_IMMEDIATELY;
/* this is used as a signal to other tun handlers that the party is over */
client->disp->user_data = client->iface->data = NULL;
client->disp->user_data = NULL;
}
if (client != NULL && client->iface != NULL) {
client->iface->data = NULL;
}
MG_FREE(client);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment