mirror of https://github.com/xqemu/xqemu.git
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>
This commit is contained in:
parent
c6dc3dd72b
commit
3d0f441891
|
@ -1443,15 +1443,17 @@ void gdb_exit(CPUArchState *env, int code)
|
||||||
if (gdbserver_fd < 0 || s->fd < 0) {
|
if (gdbserver_fd < 0 || s->fd < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (!s->chr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
|
snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
|
||||||
put_packet(s, buf);
|
put_packet(s, buf);
|
||||||
|
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
if (s->chr) {
|
qemu_chr_delete(s->chr);
|
||||||
qemu_chr_delete(s->chr);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue