diff --git a/monitor.c b/monitor.c index 6ce2a4e61b95040ea334fca31e5af0cacf6ba3e8..eefc7f083f879bd6d7216e1a9cbc3adbb0ec365d 100644 --- a/monitor.c +++ b/monitor.c @@ -280,7 +280,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 */ diff --git a/savevm.c b/savevm.c index 31dcce975ed40827db75df2d8ef7024f022e6f97..4e0fab6cd6edc0250d5e8eb4ab42dba86b98bed1 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; }