diff options
author | Paolo Bonzini | 2015-03-02 13:26:58 +0100 |
---|---|---|
committer | Michael Tokarev | 2015-03-10 06:15:34 +0100 |
commit | 3d0f44189178aab3a21a33ecf6a113b9abaea2bc (patch) | |
tree | 467b8b699bbe644ac4e60a624ed3d905ca272444 /gdbstub.c | |
parent | milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning (diff) | |
download | qemu-3d0f44189178aab3a21a33ecf6a113b9abaea2bc.tar.gz qemu-3d0f44189178aab3a21a33ecf6a113b9abaea2bc.tar.xz qemu-3d0f44189178aab3a21a33ecf6a113b9abaea2bc.zip |
gdbstub: avoid possible NULL pointer dereference
Coverity reports that s->chr is checked after put_packet dereferences it.
Move the check earlier, consistent with the code used for user-mode
emulation.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'gdbstub.c')
-rw-r--r-- | gdbstub.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1443,15 +1443,17 @@ void gdb_exit(CPUArchState *env, int code) if (gdbserver_fd < 0 || s->fd < 0) { return; } +#else + if (!s->chr) { + return; + } #endif snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); put_packet(s, buf); #ifndef CONFIG_USER_ONLY - if (s->chr) { - qemu_chr_delete(s->chr); - } + qemu_chr_delete(s->chr); #endif } |