From: Joel Anderson Date: Fri, 5 Jun 2020 10:11:03 +0000 (+0100) Subject: Fix a potential infinite loop in the Windows resource parser. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8affa48ac7c55ade04713654a22f1c56319b1195;p=binutils-gdb.git Fix a potential infinite loop in the Windows resource parser. PR 26082 * mclex.c (yylex): Add test for an empty input stream. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 9bbebf56194..161d19174f1 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2020-06-05 Joel Anderson + + PR 26082 + * mclex.c (yylex): Add test for an empty input stream. + 2020-06-04 Stephen Casner * testsuite/binutils-all/pr25662-pdp11.s: Alternate source file diff --git a/binutils/mclex.c b/binutils/mclex.c index 7e0688b07bf..1b5d5c374f3 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')