Fix coredump in mg_tun_destroy_client

PUBLISHED_FROM=56ff5afe805e4680e02183a8c3887ea60ee5ebfe
This commit is contained in:
Alexander Alashkin 2016-11-16 14:08:22 +02:00 committed by Cesanta Bot
parent 0ceee1dc05
commit e4a4b6f260

View File

@ -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) { void mg_tun_destroy_client(struct mg_tun_client *client) {
/* the dispatcher connection handler will in turn close all tunnels */ /*
client->disp->flags |= MG_F_CLOSE_IMMEDIATELY; * NOTE:
/* this is used as a signal to other tun handlers that the party is over */ * `client` is NULL in case of OOM
client->disp->user_data = client->iface->data = NULL; * `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 = NULL;
}
if (client != NULL && client->iface != NULL) {
client->iface->data = NULL;
}
MG_FREE(client); MG_FREE(client);
} }