Avoid crash in dwarf2_init_complex_target_type

After commit 35add35 ("gdb: Fix failure in gdb.base/complex-parts.exp
for x86-32"), dwarf2_init_complex_target_type can crash if "tt" is
nullptr.  This patch avoids the problem by checking for this case.

No test case because I don't know a good way to write one; it was
found by an internal AdaCore test case that apparently uses a 16 bit
floating point type.

gdb/ChangeLog:
	* dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
	against nullptr before use.

gdb/ChangeLog
2019-04-17  Tom Tromey  <tromey@adacore.com>

	* dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
	against nullptr before use.
This commit is contained in:
Tom Tromey 2019-04-16 12:12:09 -06:00
parent a7e559cc08
commit a12e57448e
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2019-04-17 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
against nullptr before use.
2019-04-17 Alan Hayward <alan.hayward@arm.com>
* nat/linux-waitpid.c (linux_debug): Call debug_vprintf.

View File

@ -17566,7 +17566,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
/* If the type we found doesn't match the size we were looking for, then
pretend we didn't find a type at all, the complex target type we
create will then be nameless. */
if (TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
if (tt != nullptr && TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
tt = nullptr;
const char *name = (tt == nullptr) ? nullptr : TYPE_NAME (tt);