aboutsummaryrefslogtreecommitdiff
path: root/binutils/mclex.c
diff options
context:
space:
mode:
authorJoel Anderson <joelanderson333@gmail.com>2020-06-05 11:11:03 +0100
committerNick Clifton <nickc@redhat.com>2020-06-05 11:11:03 +0100
commit8affa48ac7c55ade04713654a22f1c56319b1195 (patch)
treec79dda5ea17959e62300dc6b9c382cb978df2a18 /binutils/mclex.c
parent9c65eeacd88bc02aad537394930b48c50fb616d6 (diff)
downloadgdb-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/mclex.c')
-rw-r--r--binutils/mclex.c18
1 files changed, 10 insertions, 8 deletions
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')