[FYI] Fix use-after-move bug in add_thread_object

Message ID 20190711151613.3228-1-tromey@adacore.com
State New, archived
Headers

Commit Message

Tom Tromey July 11, 2019, 3:16 p.m. UTC
  commit 05b08ac1608 ("Reduce manual reference counting in
py-inferior.c") introduced a use-after-move bug in add_thread_object,
causing a test suite failure.  This patch fixes the bug.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-07-11  Tom Tromey  <tromey@adacore.com>

	* python/py-inferior.c (add_thread_object): Don't use thread_obj
	after it has been moved.
---
 gdb/ChangeLog            | 5 +++++
 gdb/python/py-inferior.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index bf43012352b..28882221a90 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -344,7 +344,7 @@  add_thread_object (struct thread_info *tp)
     return;
 
   gdbpy_ref<> event = create_thread_event_object (&new_thread_event_object_type,
-						  (PyObject *) thread_obj.get ());
+						  (PyObject *) inf_obj);
   if (event == NULL
       || evpy_emit_event (event.get (), gdb_py_events.new_thread) < 0)
     gdbpy_print_stack ();