* [pushed] Avoid crash in compile_to_object
@ 2021-01-09 18:42 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2021-01-09 18:42 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
PR 23672 points out a crash in compile_to_object. This crash came in
during a C++-ization. This patch avoids the crash.
The PR also points out another weird behavior in this code, but that
one requires some setup that I don't have here, and it seems to date
back to the introduction of the compile feature. So, it isn't
addressed here. I will leave the PR open so this bug isn't forgotten.
gdb/ChangeLog
2021-01-09 Tom Tromey <tom@tromey.com>
PR compile/23672
* compile/compile.c (compile_to_object): Avoid crash when
osabi_triplet_regexp returns NULL.
---
gdb/ChangeLog | 6 ++++++
gdb/compile/compile.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index d4c0034452d..074a865f9cc 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -703,7 +703,9 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
/* Allow triplets with or without vendor set. */
- triplet_rx = std::string (arch_rx) + "(-[^-]*)?-" + os_rx;
+ triplet_rx = std::string (arch_rx) + "(-[^-]*)?-";
+ if (os_rx != nullptr)
+ triplet_rx += os_rx;
compiler->set_triplet_regexp (triplet_rx.c_str ());
}
--
2.26.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-09 18:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09 18:42 [pushed] Avoid crash in compile_to_object Tom Tromey
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).