aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-06-16 17:48:38 -0600
committerTom Tromey <tom@tromey.com>2020-06-16 17:48:38 -0600
commitd2d1ea20aef6ed97232280b5e15a52b8d7dc7b7d (patch)
tree30e0ff51dbd59c6b7b7fefcf73c8b3c46e2fc8ec /gdb/python
parent708a2ffff5cc2d280968a6b28268d8276d391bb4 (diff)
downloadfsf-binutils-gdb-d2d1ea20aef6ed97232280b5e15a52b8d7dc7b7d.zip
fsf-binutils-gdb-d2d1ea20aef6ed97232280b5e15a52b8d7dc7b7d.tar.gz
fsf-binutils-gdb-d2d1ea20aef6ed97232280b5e15a52b8d7dc7b7d.tar.bz2
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.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-tui.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index ca88f85..95c71f1 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -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));