Fix undefined behavior in gdbserver
authorTom Tromey <tromey@adacore.com>
Tue, 20 Oct 2020 16:28:58 +0000 (10:28 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 20 Oct 2020 16:36:04 +0000 (10:36 -0600)
commita9b45cb77662d0bb8d312140eee94146f34bd3ce
treeac3f78889d431f8b80a364f4cb1904199ec6bceb
parente0c45dedd909c7a0a6621bdc9061051c185123bb
Fix undefined behavior in gdbserver

PR gdb/26742 points out some undefined behavior in gdbserver.  The bug
is that remove_thread does:

  free_one_thread (thread);
  if (current_thread == thread)
    current_thread = NULL;

However, the equality check is undefined, because "thread" has already
been freed.

This patch fixes the bug by moving the check earlier.

Tested on x86-64 Fedora 32.

2020-10-20  Tom Tromey  <tromey@adacore.com>

PR gdb/26742:
* inferiors.cc (remove_thread): Clear current_thread before
freeing the thread.
gdbserver/ChangeLog
gdbserver/inferiors.cc
This page took 0.023982 seconds and 4 git commands to generate.