Commit ca0add4b authored by Milan Crha's avatar Milan Crha Committed by Philip Withnall

gnetworkmonitor: Fix use-after-free when using from another thread

When using g_network_monitor_get_default() from another thread, it’s
possible for network-changed events to be processed after an instance of
GNetworkMonitor has been disposed, causing use-after-free problems.

Fix that by moving some of the initialisation into the GInitable.init()
chain, rather than in a main context idle callback.

This includes a unit test which probabilistically reproduces the bug
(but can’t do so deterministically due to it being a race condition).

Commit amended by Philip Withnall <> before
parent 24e80aac
Pipeline #8688 failed with stage
in 2 minutes and 16 seconds