[libvirt] [PATCHv4] network: Avoid memory leaks on networkBuildDnsmasqArgv
Eric Blake
eblake at redhat.com
Wed Feb 1 23:44:21 UTC 2012
On 02/01/2012 04:17 PM, Eric Blake wrote:
>> @@ -516,7 +520,6 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
>> int i;
>>
>> for (i = 0; i < dns->ntxtrecords; i++) {
>> - char *record = NULL;
>> if (virAsprintf(&record, "%s,%s",
>> dns->txtrecords[i].name,
>> dns->txtrecords[i].value) < 0) {
>
> Hmm, we can simplify this loop even further, by using the right function
> in the first place.
>
> ACK to what you had, and I'm squashing this in then pushing:
Serves me right for testing, then modifying, then pushing without retesting.
> - virCommandAddArgPair(cmd, "--txt-record", record);
> - VIR_FREE(record);
> + virCommandAddArg(cmd, "--txt-record");
> + virCommandAddArgFormat(cmd, "%s,%s",
> + dns->txtrecords[i].name,
> + dns->txtrecords[i].value);
ArgPair adds an equal sign. I'm pushing this followup under the
build-breaker rule (since 'make check' indeed catches the otherwise
harmless change in the generated command line).
From 0aaf88e800673b0fc204458588af6a96631a81c0 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake at redhat.com>
Date: Wed, 1 Feb 2012 16:42:33 -0700
Subject: [PATCH] network: fix testsuite regression
I slightly botched commit be9fb5a - I converted '--arg=value' to
'--arg value', which has no semantic change, but did trip up the
testsuite.
* src/network/bridge_driver.c (networkBuildDnsmasqArgv): Restore
expected output.
---
src/network/bridge_driver.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 220f99e..57ebb9f 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -520,8 +520,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
int i;
for (i = 0; i < dns->ntxtrecords; i++) {
- virCommandAddArg(cmd, "--txt-record");
- virCommandAddArgFormat(cmd, "%s,%s",
+ virCommandAddArgFormat(cmd, "--txt-record=%s,%s",
dns->txtrecords[i].name,
dns->txtrecords[i].value);
}
--
1.7.7.6
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120201/4929f6b3/attachment-0001.sig>
More information about the libvir-list
mailing list