[PATCH] binutils: guard against missing enum type

Alhuda Khan alhuda@research.digiscrypt.com
Mon Nov 23 10:57:51 GMT 2026


I am submitting a patch for a NULL-pointer dereference in the DWARF enumerator handling code in GNU Binutils.

The issue occurs in insert_element_in_list() when processing a DW_TAG_enumerator. The code accesses enum_type_list.tail without checking whether it is NULL before passing it to get_or_create_enum_constant().

Malformed DWARF input can trigger this condition and cause objdump to crash.

The patch adds a NULL check before the function call, preventing the invalid access.

I reproduced the issue using a malformed DWARF object file. The reproducer exited with status 134 before the fix and status 0 after the fix.

The patched Binutils test suite reported 371 expected passes, 0 unexpected failures, and 3 unsupported tests.

Thank you for your time and consideration.

Signed-off-by: Alhuda Khan <alhuda@research.digiscrypt.com>
---
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 2b8cd482bc8..5088b5305d9 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -3287,6 +3287,8 @@ insert_element_in_list (enum dwarf_tag dw_tag,
       break;
     case DW_TAG_enumerator:
       {
+	if (enum_type_list.tail == NULL)
+	  break;
 	enum_constant *ec = get_or_create_enum_constant (enum_type_list.tail,
 							 die_offset);
 	if (dw_attr == DW_AT_name)


More information about the Binutils mailing list