[binutils-gdb] segv in debug_write_type
Alan Modra
amodra@sourceware.org
Mon Oct 6 03:05:29 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=049a70652a9a1cca7d3f3445f6d649fb125ecabd
commit 049a70652a9a1cca7d3f3445f6d649fb125ecabd
Author: Alan Modra <amodra@gmail.com>
Date: Mon Oct 6 13:01:19 2025 +1030
segv in debug_write_type
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:
---
binutils/debug.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
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;
More information about the Binutils-cvs
mailing list