summaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-05-31 14:00:27 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2013-06-11 17:28:24 -0500
commitbaa8a8b44452f4a51de5ba33089dd8882d3fa545 (patch)
tree3a94f1f255986a13f386b869c599342bc66ce851 /savevm.c
parent327e75b537c3b7bc25ac83bedeb4a40c782796c3 (diff)
downloadqemu-baa8a8b44452f4a51de5ba33089dd8882d3fa545.tar.gz
qemu-baa8a8b44452f4a51de5ba33089dd8882d3fa545.tar.bz2
qemu-baa8a8b44452f4a51de5ba33089dd8882d3fa545.zip
do not check pointers after dereferencing them
Two instances, both spotted by Coverity. In one, two blocks were swapped. In the other, the check is not needed anymore. Cc: qemu-stable@nongnu.org Cc: qemu-trivial@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> (cherry picked from commit a4cc73d629d43c8a4d171d043ff229a959df3ca6) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/savevm.c b/savevm.c
index 31dcce975e..4e0fab6cd6 100644
--- a/savevm.c
+++ b/savevm.c
@@ -322,13 +322,13 @@ QEMUFile *qemu_popen_cmd(const char *command, const char *mode)
FILE *stdio_file;
QEMUFileStdio *s;
- stdio_file = popen(command, mode);
- if (stdio_file == NULL) {
+ if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
+ fprintf(stderr, "qemu_popen: Argument validity check failed\n");
return NULL;
}
- if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
- fprintf(stderr, "qemu_popen: Argument validity check failed\n");
+ stdio_file = popen(command, mode);
+ if (stdio_file == NULL) {
return NULL;
}