From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [pushed] Fix crash in gdb_rl_callback_handler
Date: Mon, 15 Apr 2024 12:53:38 -0600 [thread overview]
Message-ID: <20240415185338.3904592-1-tromey@adacore.com> (raw)
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.
---
gdb/event-top.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/gdb/event-top.c b/gdb/event-top.c
index f0c07ba7f64..6a2a75fe3dc 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
{
--
2.43.0
reply other threads:[~2024-04-15 18:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240415185338.3904592-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).