diff options
author | Tom Tromey <tromey@adacore.com> | 2022-08-12 13:15:01 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-08-31 11:03:40 -0600 |
commit | 058dc2c95935d54caa8891613a1080d57665fc43 (patch) | |
tree | b32d1a2bb50f93731aee58c0137b3daea4b5bc6b /gdb/event-top.c | |
parent | 1e28eebbbc34ebec69ea4913f7e8d19352e35630 (diff) | |
download | fsf-binutils-gdb-058dc2c95935d54caa8891613a1080d57665fc43.zip fsf-binutils-gdb-058dc2c95935d54caa8891613a1080d57665fc43.tar.gz fsf-binutils-gdb-058dc2c95935d54caa8891613a1080d57665fc43.tar.bz2 |
Fix interpreter-exec crash
PR mi/10347 points out that using interpreter-exec inside of a
"define" command will crash gdb. The bug here is that
gdb_setup_readline doesn't check for the case where instream==nullptr.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=10347
Diffstat (limited to 'gdb/event-top.c')
-rw-r--r-- | gdb/event-top.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/event-top.c b/gdb/event-top.c index 1b522a7..290c3d8 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -1332,8 +1332,10 @@ gdb_setup_readline (int editing) /* If the input stream is connected to a terminal, turn on editing. However, that is only allowed on the main UI, as we can only have - one instance of readline. */ - if (ISATTY (ui->instream) && editing && ui == main_ui) + one instance of readline. Also, INSTREAM might be nullptr when + executing a user-defined command. */ + if (ui->instream != nullptr && ISATTY (ui->instream) + && editing && ui == main_ui) { /* Tell gdb that we will be using the readline library. This could be overwritten by a command in .gdbinit like 'set |