From 55cec560b8005329e18adddc72b5dc089679f081 Mon Sep 17 00:00:00 2001 From: pfg Date: Thu, 12 Dec 2013 19:01:50 +0000 Subject: [PATCH] MFC r258712; libcpp: fix an underflow. Similar fix seen in Apple's gcc42. Obtained from: OpenBSD (Rev 1.2) MFC after: 2 weeks git-svn-id: svn://svn.freebsd.org/base/stable/10@259271 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/gcclibs/libcpp/charset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/gcclibs/libcpp/charset.c b/contrib/gcclibs/libcpp/charset.c index 78c898167..6361f8c51 100644 --- a/contrib/gcclibs/libcpp/charset.c +++ b/contrib/gcclibs/libcpp/charset.c @@ -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'; -- 2.45.0