]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix crash in amd64-tdep.c
authorTom Tromey <tromey@adacore.com>
Tue, 6 Sep 2022 14:44:52 +0000 (08:44 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 3 Jan 2023 15:45:00 +0000 (08:45 -0700)
amd64-tdep.c could crash when 'finish'ing from a function whose return
type had variable length.  In this situation, the value will be passed
by reference, and this patch avoids the crash.

(Note that this does not fully fix the bug reported, but it does fix
the crash, so it seems worthwhile to land independently.)

gdb/amd64-tdep.c

index b8cd81880449727872f32723ac6fc444cd678d7f..0f2dab8b479a2d86d1ecafb7feb9f031132e3ae5 100644 (file)
@@ -666,7 +666,8 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2])
        loc_bitpos attributes, which will cause an assert to trigger within
        the unaligned field check.  As classes with virtual bases are not
        trivially copyable, checking that first avoids this problem.  */
-  if (type->length () > 16
+  if (TYPE_HAS_DYNAMIC_LENGTH (type)
+      || type->length () > 16
       || !language_pass_by_reference (type).trivially_copyable
       || amd64_has_unaligned_fields (type))
     {