From: Tom Tromey Date: Tue, 16 Apr 2019 18:12:09 +0000 (-0600) Subject: Avoid crash in dwarf2_init_complex_target_type X-Git-Tag: binutils-2_33~1538 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a12e57448ecf2644e3ddc98bbd4bbb914a5f8c92;p=external%2Fbinutils.git 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 * dwarf2read.c (dwarf2_init_complex_target_type): Check "tt" against nullptr before use. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2fb4b87..ef77fdb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-04-17 Tom Tromey + + * dwarf2read.c (dwarf2_init_complex_target_type): Check "tt" + against nullptr before use. + 2019-04-17 Alan Hayward * nat/linux-waitpid.c (linux_debug): Call debug_vprintf. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0873028..16bf240 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -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);