On Sat, Aug 15, 2015 at 09:18:14AM -0400, John Ferlan wrote:
Coverity complained that 'vm' wasn't initialized before
jumping to
cleanup: and calling virDomainObjEndAPI if the VIR_STRDUP fails.
Rather than initialize vm = NULL, I moved the VIR_STRDUP closer to
usage and used endjob for goto.
Wild pointers should not exist. At all. It's very subjective, but I
just don't like them. ACK if you also initialize that pointer to
NULL; that won't hurt anyone and will avoid possible future problems.
Martin
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_driver.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3683591..a54a3dd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19902,9 +19902,6 @@ static int qemuDomainRename(virDomainPtr dom,
virCheckFlags(0, ret);
- if (VIR_STRDUP(new_dom_name, new_name) < 0)
- goto cleanup;
-
if (!(vm = qemuDomObjFromDomain(dom)))
goto cleanup;
@@ -19940,6 +19937,9 @@ static int qemuDomainRename(virDomainPtr dom,
goto endjob;
}
+ if (VIR_STRDUP(new_dom_name, new_name) < 0)
+ goto endjob;
+
if (virAsprintf(&rename_log_msg, ": domain %s has been renamed to
%s\n",
vm->def->name, new_name) < 0) {
goto endjob;
--
2.1.0
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list