Reduce the scope of the variable to get it freed for every controller
processed.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_command.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index db8584243c..298a1c3fea 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3198,12 +3198,12 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
virQEMUCapsPtr qemuCaps,
virDomainControllerType type)
{
- char *devstr = NULL;
int ret = -1;
size_t i;
for (i = 0; i < def->ncontrollers; i++) {
virDomainControllerDefPtr cont = def->controllers[i];
+ VIR_AUTOFREE(char *) devstr = NULL;
if (cont->type != type)
continue;
@@ -3236,7 +3236,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
continue;
}
- VIR_FREE(devstr);
if (qemuBuildControllerDevStr(def, cont, qemuCaps, &devstr) < 0)
goto cleanup;
@@ -3251,7 +3250,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
ret = 0;
cleanup:
- VIR_FREE(devstr);
return ret;
}
--
2.19.2