From: Ján Tomko Date: Tue, 15 Jan 2019 16:59:17 +0000 (+0100) Subject: qemuBuildControllersByTypeCommandLine: free devstr in the cleanup X-Git-Tag: v5.1.0-rc1~363 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc1c16bccd4deb86848a3f37ccb55831ed8ce2f2;p=thirdparty%2Flibvirt.git qemuBuildControllersByTypeCommandLine: free devstr in the cleanup section Signed-off-by: Ján Tomko Reviewed-by: Cole Robinson --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 361a345fe5..21823fdd12 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3145,12 +3145,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]; - char *devstr; if (cont->type != type) continue; @@ -3183,23 +3183,22 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd, continue; } + VIR_FREE(devstr); if (qemuBuildControllerDevStr(def, cont, qemuCaps, &devstr) < 0) goto cleanup; if (devstr) { - if (qemuCommandAddExtDevice(cmd, &cont->info) < 0) { - VIR_FREE(devstr); + if (qemuCommandAddExtDevice(cmd, &cont->info) < 0) goto cleanup; - } virCommandAddArg(cmd, "-device"); virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); } } ret = 0; cleanup: + VIR_FREE(devstr); return ret; }