1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

vhost: remove from defer binding on destroy

If a vhost is removed, it should remove references to it from the
defer binding list to avoid dangling pointers, which can crash the
application.
This commit is contained in:
Dmitry Potapov 2022-03-16 15:24:22 +03:00 committed by Andy Green
parent ba84a1d3b5
commit 39f6379c0c

View file

@ -1437,6 +1437,20 @@ __lws_vhost_destroy2(struct lws_vhost *vh)
// lwsl_info("%s: %s\n", __func__, vh->name);
/*
* remove ourselves from the defer binding list
*/
lws_start_foreach_llp(struct lws_vhost **, pv,
vh->context->no_listener_vhost_list) {
if (*pv == vh) {
lwsl_debug("deferred iface: removing vh %s\n",
(*pv)->name);
*pv = vh->no_listener_vhost_list;
vh->no_listener_vhost_list = NULL;
break;
}
} lws_end_foreach_llp(pv, no_listener_vhost_list);
/*
* let the protocols destroy the per-vhost protocol objects
*/