]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
segv in debug_write_type
authorAlan Modra <amodra@gmail.com>
Mon, 6 Oct 2025 02:31:19 +0000 (13:01 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 6 Oct 2025 03:01:31 +0000 (13:31 +1030)
In commit 6c3458a8b7ee I claimed that u.kenum is always non-NULL,
which is true for debug_make_enum_type, but not for enums made by
debug_make_undefined_tagged_type.  Fix that oversight

PR 32829
* debug.c (debug_write_type): Handle NULL u.kenum.
(debug_type_samep): Likewise.

binutils/debug.c

index 465b18e7c0aaac0f4d282045ee2251f7bddb59e9..78cdd3ceca86a19812ae3ba2131205567d04e243 100644 (file)
@@ -2554,8 +2554,9 @@ debug_write_type (struct debug_handle *info,
     case DEBUG_KIND_UNION_CLASS:
       return debug_write_class_type (info, fns, fhandle, type, tag);
     case DEBUG_KIND_ENUM:
-      return (*fns->enum_type) (fhandle, tag, type->u.kenum->names,
-                               type->u.kenum->values);
+      return (*fns->enum_type) (fhandle, tag,
+                               type->u.kenum ? type->u.kenum->names : NULL,
+                               type->u.kenum ? type->u.kenum->values : NULL);
     case DEBUG_KIND_POINTER:
       if (! debug_write_type (info, fns, fhandle, type->u.kpointer,
                              (struct debug_name *) NULL))
@@ -3094,7 +3095,11 @@ debug_type_samep (struct debug_handle *info, struct debug_type_s *t1,
       break;
 
     case DEBUG_KIND_ENUM:
-      if (t1->u.kenum->names == NULL)
+      if (t1->u.kenum == NULL)
+       ret = t2->u.kenum == NULL;
+      else if (t2->u.kenum == NULL)
+       ret = false;
+      else if (t1->u.kenum->names == NULL)
        ret = t2->u.kenum->names == NULL;
       else if (t2->u.kenum->names == NULL)
        ret = false;