mirror of
https://github.com/cesanta/mongoose.git
synced 2025-06-12 20:59:03 +08:00
Fix coredump in mg_tun_destroy_client
PUBLISHED_FROM=56ff5afe805e4680e02183a8c3887ea60ee5ebfe
This commit is contained in:
parent
0ceee1dc05
commit
e4a4b6f260
22
mongoose.c
22
mongoose.c
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user