diff options
author | Tom Tromey <tom@tromey.com> | 2021-01-09 11:38:41 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-01-09 11:38:41 -0700 |
commit | 54585eee2e10de40b160c750dbe8bf15dcbf4527 (patch) | |
tree | 61824074d73cba3b26d0871ee622d8dd55b238aa /gdb/compile/compile.c | |
parent | bc167b6b3eb81de168c54aed4a8f0d1fdaa065e2 (diff) | |
download | gdb-54585eee2e10de40b160c750dbe8bf15dcbf4527.zip gdb-54585eee2e10de40b160c750dbe8bf15dcbf4527.tar.gz gdb-54585eee2e10de40b160c750dbe8bf15dcbf4527.tar.bz2 |
Avoid crash in compile_to_object
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.
Diffstat (limited to 'gdb/compile/compile.c')
-rw-r--r-- | gdb/compile/compile.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index d4c0034..074a865 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 ()); } |