win32 pcapif: fix "heap-use-after-free" on shutdown

This commit is contained in:
Simon Goldschmidt 2023-09-27 21:28:29 +02:00
parent 3792075baf
commit f7fe057821

View File

@ -679,12 +679,17 @@ pcapif_shutdown(struct netif *netif)
#endif /* PCAPIF_RX_USE_THREAD */
if (pa->adapter) {
pcap_breakloop(pa->adapter);
pcap_close(pa->adapter);
}
#if PCAPIF_RX_USE_THREAD
/* wait for rxthread to end */
while(pa->rx_running);
while (pa->rx_running) {
Sleep(100);
}
#endif /* PCAPIF_RX_USE_THREAD */
if (pa->adapter) {
pcap_close(pa->adapter);
pa->adapter = NULL;
}
#if PCAPIF_HANDLE_LINKSTATE
pcapifh_linkstate_close(pa->link_state);
#endif /* PCAPIF_HANDLE_LINKSTATE */