This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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)
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]