diff options
author | Tom Tromey <tromey@redhat.com> | 2006-12-28 18:45:48 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2006-12-28 18:45:48 +0000 |
commit | 30b0edc057bf0cda15810a74bb1c4a28381cee42 (patch) | |
tree | 1d3f02bb630179f0bf2fe0b14fc0c2031d5a3f7a /libcpp/charset.c | |
parent | c5bfb0451df393fe3daedd21ed2619eb5f7f5f20 (diff) | |
download | gcc-30b0edc057bf0cda15810a74bb1c4a28381cee42.zip gcc-30b0edc057bf0cda15810a74bb1c4a28381cee42.tar.gz gcc-30b0edc057bf0cda15810a74bb1c4a28381cee42.tar.bz2 |
re PR preprocessor/30001 (out-of-bounds access when processing empty file)
PR preprocessor/30001:
* charset.c (_cpp_convert_input): Check that to.len is greater
than zero.
From-SVN: r120245
Diffstat (limited to 'libcpp/charset.c')
-rw-r--r-- | libcpp/charset.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libcpp/charset.c b/libcpp/charset.c index 78c8981..d132360 100644 --- a/libcpp/charset.c +++ b/libcpp/charset.c @@ -1,5 +1,5 @@ /* CPP Library - charsets - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. Broken out of c-lex.c Apr 2003, adding valid C99 UCN ranges. @@ -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 && to.text[to.len - 1] == '\r') to.text[to.len] = '\r'; else to.text[to.len] = '\n'; |