]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix a potential infinite loop in the Windows resource parser.
authorJoel Anderson <joelanderson333@gmail.com>
Fri, 5 Jun 2020 10:11:03 +0000 (11:11 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 5 Jun 2020 10:11:03 +0000 (11:11 +0100)
PR 26082
* mclex.c (yylex): Add test for an empty input stream.

binutils/ChangeLog
binutils/mclex.c

index 9bbebf561949c4afd9de7c2b2554a862477336d8..161d19174f19f8b96e731716bdd86257be7b0743 100644 (file)
@@ -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
index 7e0688b07bfe02afa5ef174c234f32a10ca139de..1b5d5c374f34251f76c99aae5b2365924e715958 100644 (file)
@@ -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')