diff mbox series

cpplib: Fix off-by-one error

Message ID 7d85ffb2-e00f-1496-0d84-559231fa4a5a@acm.org
State New
Headers show
Series cpplib: Fix off-by-one error | expand

Commit Message

Nathan Sidwell Nov. 3, 2020, 4:34 p.m. UTC
I noticed a fencepost error in the preprocessor.  We should be
checking if the next char is at the limit, not the current char	(which
can't be, because we're looking at it).

	libcpp/
	* lex.c (_cpp_clean_line): Fix DOS off-by-one error.

pushing to trunk
diff mbox series

Patch

diff --git i/libcpp/lex.c w/libcpp/lex.c
index fb222924c8c..1d522030a3c 100644
--- i/libcpp/lex.c
+++ w/libcpp/lex.c
@@ -1062,7 +1062,7 @@  _cpp_clean_line (cpp_reader *pfile)
       d = (uchar *) s;
 
       /* Handle DOS line endings.  */
-      if (*s == '\r' && s != buffer->rlimit && s[1] == '\n')
+      if (*s == '\r' && s + 1 != buffer->rlimit && s[1] == '\n')
 	s++;
     }