diff options
author | Joel Anderson <joelanderson333@gmail.com> | 2020-06-05 11:11:03 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-06-05 11:11:03 +0100 |
commit | 8affa48ac7c55ade04713654a22f1c56319b1195 (patch) | |
tree | c79dda5ea17959e62300dc6b9c382cb978df2a18 /binutils | |
parent | 9c65eeacd88bc02aad537394930b48c50fb616d6 (diff) | |
download | gdb-8affa48ac7c55ade04713654a22f1c56319b1195.zip gdb-8affa48ac7c55ade04713654a22f1c56319b1195.tar.gz gdb-8affa48ac7c55ade04713654a22f1c56319b1195.tar.bz2 |
Fix a potential infinite loop in the Windows resource parser.
PR 26082
* mclex.c (yylex): Add test for an empty input stream.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 5 | ||||
-rw-r--r-- | binutils/mclex.c | 18 |
2 files changed, 15 insertions, 8 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 9bbebf5..161d191 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2020-06-05 Joel Anderson <joelanderson333@gmail.com> + + PR 26082 + * mclex.c (yylex): Add test for an empty input stream. + 2020-06-04 Stephen Casner <casner@acm.org> * testsuite/binutils-all/pr25662-pdp11.s: Alternate source file diff --git a/binutils/mclex.c b/binutils/mclex.c index 7e0688b..1b5d5c3 100644 --- a/binutils/mclex.c +++ b/binutils/mclex.c @@ -337,17 +337,19 @@ yylex (void) if (mclex_want_line) { start_token = input_stream_pos; + if (input_stream_pos[0] == 0) + return -1; if (input_stream_pos[0] == '.' && (input_stream_pos[1] == '\n' || (input_stream_pos[1] == '\r' && input_stream_pos[2] == '\n'))) - { - mclex_want_line = FALSE; - while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') - ++input_stream_pos; - if (input_stream_pos[0] == '\n') - ++input_stream_pos; - return MCENDLINE; - } + { + mclex_want_line = FALSE; + while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') + ++input_stream_pos; + if (input_stream_pos[0] == '\n') + ++input_stream_pos; + return MCENDLINE; + } while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') ++input_stream_pos; if (input_stream_pos[0] == '\n') |