The virCHMonitorClose() is meant to be called when monitor to cloud-hypervisor process closes. It removes the socket and frees string containing path to the socket. In general, there is a problem with the following pattern: if (var) { do_something(); g_free(var); } because if the pattern executes twice the variable is freed twice. That's why we have VIR_FREE() macro. Well, replace plain g_free() with g_clear_pointer(). Mind you, this is NOT a destructor where clearing pointers is needless. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/ch/ch_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index ccd04cfbd1..18ca5a764e 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -626,7 +626,7 @@ void virCHMonitorClose(virCHMonitor *mon) VIR_WARN("Unable to remove CH socket file '%s'", mon->socketpath); } - g_free(mon->socketpath); + g_clear_pointer(&mon->socketpath, g_free); } virObjectUnref(mon); -- 2.45.2