diff options
author | Nick Clifton <nickc@redhat.com> | 2019-11-21 17:02:40 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2019-11-21 17:04:05 +0000 |
commit | b52696f9e567da157b152ae641f064507f993969 (patch) | |
tree | db1a4f473dd5440326326ab69447f36bb0cb71b9 /ld | |
parent | 2e84f897e51ee67ab8d3ddf848c4a2bfebbd7173 (diff) | |
download | gdb-b52696f9e567da157b152ae641f064507f993969.zip gdb-b52696f9e567da157b152ae641f064507f993969.tar.gz gdb-b52696f9e567da157b152ae641f064507f993969.tar.bz2 |
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.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 5 | ||||
-rw-r--r-- | ld/ldlang.h | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index e4e3f74..5a3b2dd 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -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 diff --git a/ld/ldlang.h b/ld/ldlang.h index 8cc5cf7..3e3e6a0 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) |