https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78811
--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> --- Author: dmalcolm Date: Thu Dec 15 18:05:05 2016 New Revision: 243721 URL: https://gcc.gnu.org/viewcvs?rev=243721&root=gcc&view=rev Log: Fix use-after-free lexing unterminated raw strings (PR preprocessor/78811) gcc/ChangeLog: PR preprocessor/78680 PR preprocessor/78811 * input.c (struct selftest::lexer_test): Add field m_implicitly_expect_EOF. (selftest::lexer_error_sink): New class. (selftest::lexer_error_sink::s_singleton): New global. (selftest::lexer_test::lexer_test): Initialize new field "m_implicitly_expect_EOF". (selftest::lexer_test::~lexer_test): Conditionalize the check for the EOF token on the new field. (selftest::test_lexer_string_locations_raw_string_unterminated): New function. (selftest::input_c_tests): Call the new test. libcpp/ChangeLog: PR preprocessor/78680 PR preprocessor/78811 * lex.c (_cpp_lex_direct): Only determine the end-location of the token and build a range for non-reserved start locations. Do not do it for EOF tokens. Modified: trunk/gcc/ChangeLog trunk/gcc/input.c trunk/libcpp/ChangeLog trunk/libcpp/lex.c