summaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-05-31 14:00:27 +0200
committerMichael Tokarev <mjt@tls.msk.ru>2013-06-01 14:25:39 +0400
commita4cc73d629d43c8a4d171d043ff229a959df3ca6 (patch)
treee4217378c556489b6f2f6e9b747978d931e7527b /savevm.c
parentcd2e64ce306910f6a627d899e6779eda33f8511c (diff)
downloadqemu-a4cc73d629d43c8a4d171d043ff229a959df3ca6.tar.gz
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>
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;
}