diff options
author | Tom Tromey <tromey@adacore.com> | 2024-04-15 12:52:05 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-04-15 12:52:05 -0600 |
commit | ef076b0377c931c8743841572ad5eccafa48c30f (patch) | |
tree | 9a3986f133471748c979f8bd25fcc69d116ef10c | |
parent | 12406b2cdab40fd05df65c4fe4aabaf4882fcc8e (diff) | |
download | gdb-ef076b0377c931c8743841572ad5eccafa48c30f.zip gdb-ef076b0377c931c8743841572ad5eccafa48c30f.tar.gz gdb-ef076b0377c931c8743841572ad5eccafa48c30f.tar.bz2 |
Fix crash in gdb_rl_callback_handler
commit bdcd50f9 ("Strip trailing newlines from input string")
introduced a crash in eof-exit.exp. This patch fixes the problem by
adding a NULL check in the appropriate spot.
Regression tested on x86-64 Fedora 38. I'm checking this in.
-rw-r--r-- | gdb/event-top.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gdb/event-top.c b/gdb/event-top.c index f0c07ba..6a2a75f 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -254,10 +254,13 @@ gdb_rl_callback_handler (char *rl) noexcept /* In bracketed paste mode, pasting a complete line can result in a literal newline appearing at the end of LINE. However, we never want this in gdb. */ - size_t len = strlen (rl); - while (len > 0 && (rl[len - 1] == '\r' || rl[len - 1] == '\n')) - --len; - rl[len] = '\0'; + if (rl != nullptr) + { + size_t len = strlen (rl); + while (len > 0 && (rl[len - 1] == '\r' || rl[len - 1] == '\n')) + --len; + rl[len] = '\0'; + } try { |