diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 519a473995..29060139d7 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5466,8 +5466,7 @@ networkPortSetParameters(virNetworkPortPtr port, goto cleanup; virNetDevBandwidthFree(portdef->bandwidth); - portdef->bandwidth = bandwidth; - bandwidth = NULL; + portdef->bandwidth = g_steal_pointer(&bandwidth); if (virNetworkPortDefSaveStatus(portdef, dir) < 0) goto cleanup; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9a6934f30f..7026c5aef0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10372,8 +10372,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, virNetDevBandwidthFree(net->bandwidth); if (newBandwidth->in || newBandwidth->out) { - net->bandwidth = newBandwidth; - newBandwidth = NULL; + net->bandwidth = g_steal_pointer(&newBandwidth); } else { net->bandwidth = NULL; } @@ -10391,8 +10390,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (persistentNet) { if (!persistentNet->bandwidth) { - persistentNet->bandwidth = bandwidth; - bandwidth = NULL; + persistentNet->bandwidth = g_steal_pointer(&bandwidth); } else { if (bandwidth->in) { VIR_FREE(persistentNet->bandwidth->in);