libcpp: fix an underflow.

Obtained from:	OpenBSD (Rev 1.2)
MFC after:	2 weeks
This commit is contained in:
Pedro F. Giffuni 2013-11-28 16:36:03 +00:00
parent a19b3f74af
commit 729f64d6ae
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=258712

View File

@ -1628,7 +1628,7 @@ _cpp_convert_input (cpp_reader *pfile, const char *input_charset,
terminate with another \r, not an \n, so that we do not mistake
the \r\n sequence for a single DOS line ending and erroneously
issue the "No newline at end of file" diagnostic. */
if (to.text[to.len - 1] == '\r')
if (to.len > 0 && to.text[to.len - 1] == '\r')
to.text[to.len] = '\r';
else
to.text[to.len] = '\n';