From a4cc73d629d43c8a4d171d043ff229a959df3ca6 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 31 May 2013 14:00:27 +0200 Subject: 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 Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- savevm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'savevm.c') diff --git a/savevm.c b/savevm.c index 31dcce975..4e0fab6cd 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; } -- cgit v1.2.3