segv in debug_write_type
Alan Modra
amodra@gmail.com
Mon Oct 6 03:04:12 GMT 2025
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.
diff --git a/binutils/debug.c b/binutils/debug.c
index 465b18e7c0a..78cdd3ceca8 100644
--- a/binutils/debug.c
+++ b/binutils/debug.c
@@ -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;
--
Alan Modra
More information about the Binutils
mailing list