Let's annotate virMacMap variables in bridge_driver.c with g_autoptr() so that they are automatically freed upon error. This may look like a needless commit, since there's no memory leak currently, but it simplifies the next commit. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/network/bridge_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7ad9f278a2..a07af55390 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -450,7 +450,7 @@ networkUpdateState(virNetworkObj *obj, virNetworkDef *def; virNetworkDriverState *driver = opaque; g_autoptr(dnsmasqCaps) dnsmasq_caps = networkGetDnsmasqCaps(driver); - virMacMap *macmap; + g_autoptr(virMacMap) macmap = NULL; g_autofree char *macMapFile = NULL; VIR_LOCK_GUARD lock = virObjectLockGuard(obj); @@ -476,6 +476,7 @@ networkUpdateState(virNetworkObj *obj, return -1; virNetworkObjSetMacMap(obj, macmap); + macmap = NULL; break; @@ -1938,7 +1939,7 @@ networkStartNetworkVirtual(virNetworkDriverState *driver, virErrorPtr save_err = NULL; virNetworkIPDef *ipdef; virNetDevIPRoute *routedef; - virMacMap *macmap; + g_autoptr(virMacMap) macmap = NULL; g_autofree char *macMapFile = NULL; bool dnsmasqStarted = false; bool devOnline = false; -- 2.35.1