Fix potentially undefined behaviour in the linker when parsing input statements.

* ldlang.h (LANG_FOR_EACH_INPUT_STATEMENT): Check for an empty
	file chain before examining the first input statement.
This commit is contained in:
Nick Clifton 2019-11-21 17:02:40 +00:00
parent 2e84f897e5
commit b52696f9e5
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,8 @@
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.
2019-11-21 Alan Modra <amodra@gmail.com>
PR 46

View File

@ -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)