Skip to content
Snippets Groups Projects
Commit 3d0f4418 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Michael Tokarev
Browse files

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: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
parent c6dc3dd7
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment