diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index ae7a8603b16454baf872ea83e346e37db6b7f186..a92003538a23fea5579fced7fc2ee4ea485ae2e7 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -134,8 +134,8 @@ virNetworkIpDefClear(virNetworkIpDefPtr def) VIR_FREE(def->family); VIR_FREE(def->ranges); - while (def->nhosts--) - virNetworkDHCPHostDefClear(&def->hosts[def->nhosts]); + while (def->nhosts) + virNetworkDHCPHostDefClear(&def->hosts[--def->nhosts]); VIR_FREE(def->hosts); VIR_FREE(def->tftproot); @@ -152,8 +152,8 @@ virNetworkDNSTxtDefClear(virNetworkDNSTxtDefPtr def) static void virNetworkDNSHostDefClear(virNetworkDNSHostDefPtr def) { - while (def->nnames--) - VIR_FREE(def->names[def->nnames]); + while (def->nnames) + VIR_FREE(def->names[--def->nnames]); VIR_FREE(def->names); } @@ -170,18 +170,18 @@ static void virNetworkDNSDefClear(virNetworkDNSDefPtr def) { if (def->txts) { - while (def->ntxts--) - virNetworkDNSTxtDefClear(&def->txts[def->ntxts]); + while (def->ntxts) + virNetworkDNSTxtDefClear(&def->txts[--def->ntxts]); VIR_FREE(def->txts); } if (def->hosts) { - while (def->nhosts--) - virNetworkDNSHostDefClear(&def->hosts[def->nhosts]); + while (def->nhosts) + virNetworkDNSHostDefClear(&def->hosts[--def->nhosts]); VIR_FREE(def->hosts); } if (def->srvs) { - while (def->nsrvs--) - virNetworkDNSSrvDefClear(&def->srvs[def->nsrvs]); + while (def->nsrvs) + virNetworkDNSSrvDefClear(&def->srvs[--def->nsrvs]); VIR_FREE(def->srvs); } } @@ -200,6 +200,7 @@ virNetworkForwardDefClear(virNetworkForwardDefPtr def) virNetworkForwardIfDefClear(&def->ifs[ii]); } VIR_FREE(def->ifs); + def->nifs = def->npfs = 0; } void