Fix crash when TUI window creation fails
If a TUI window is written in Python, and if the window construction function fails, then gdb will crash. This patch fixes the crash. gdb/ChangeLog 2020-06-16 Tom Tromey <tom@tromey.com> * python/py-tui.c (tui_py_window::~tui_py_window): Handle case where m_window==nullptr. gdb/testsuite/ChangeLog 2020-06-16 Tom Tromey <tom@tromey.com> * gdb.python/tui-window.py (failwin): New function. Register it as a TUI window type. * gdb.python/tui-window.exp: Create new "fail" layout. Test it.
This commit is contained in:
+4
-1
@@ -133,7 +133,10 @@ tui_py_window::~tui_py_window ()
|
||||
{
|
||||
gdbpy_enter enter_py (get_current_arch (), current_language);
|
||||
|
||||
if (PyObject_HasAttrString (m_window.get (), "close"))
|
||||
/* This can be null if the user-provided Python construction
|
||||
function failed. */
|
||||
if (m_window != nullptr
|
||||
&& PyObject_HasAttrString (m_window.get (), "close"))
|
||||
{
|
||||
gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "close",
|
||||
nullptr));
|
||||
|
||||
Reference in New Issue
Block a user