This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Commit: Fix potential null pointer dereference in linker
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Thu, 21 Nov 2019 17:02:10 +0000
- Subject: Commit: Fix potential null pointer dereference in linker
Hi Guys,
I am applying the patch below to fix a potential null pointer
dereference in the linker. This also fixes an annoying message from
the undefined behaviour sanitizer...
Cheers
Nick
ld/ChangeLog
2019-11-21 Nick Clifton <nickc@redhat.com>
* ldlang.h (LANG_FOR_EACH_INPUT_STATEMENT): Check for an empty
file chain before examining the first input statement.
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 8cc5cf7f90..3e3e6a0289 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -574,7 +574,7 @@ extern asection *section_for_dot
#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
lang_input_statement_type *statement; \
- for (statement = &file_chain.head->input_statement; \
+ for (statement = file_chain.head == NULL ? NULL : &file_chain.head->input_statement; \
statement != NULL; \
statement = statement->next)