]> git.proxmox.com Git - qemu.git/commitdiff
do not check pointers after dereferencing them
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 31 May 2013 12:00:27 +0000 (14:00 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 11 Jun 2013 22:28:24 +0000 (17:28 -0500)
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>
monitor.c
savevm.c

index 62aaebe660eeb2fc4e737b3d721f97829e2c69e7..dee980ca5faeae319a43a6be8d4ef54b60d9b79b 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -281,7 +281,7 @@ void monitor_flush(Monitor *mon)
     buf = qstring_get_str(mon->outbuf);
     len = qstring_get_length(mon->outbuf);
 
-    if (mon && len && !mon->mux_out) {
+    if (len && !mon->mux_out) {
         rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len);
         if (rc == len) {
             /* all flushed */
index 31dcce975ed40827db75df2d8ef7024f022e6f97..4e0fab6cd6edc0250d5e8eb4ab42dba86b98bed1 100644 (file)
--- 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;
     }