From 1e39ea08122ef6db924f2ae622e03d4bedde8cd5 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 22 Sep 2012 06:51:59 +0000 Subject: compiler, runtime: Reject surrogate pair converting int to string. From-SVN: r191636 --- gcc/go/gofrontend/lex.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/go/gofrontend/lex.cc') diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc index 25aaeb7..6add84e 100644 --- a/gcc/go/gofrontend/lex.cc +++ b/gcc/go/gofrontend/lex.cc @@ -1312,6 +1312,12 @@ Lex::append_char(unsigned int v, bool is_character, std::string* str, // Turn it into the "replacement character". v = 0xfffd; } + if (v >= 0xd800 && v < 0xe000) + { + warning_at(location, 0, + "unicode code point 0x%x is invalid surrogate pair", v); + v = 0xfffd; + } if (v <= 0xffff) { buf[0] = 0xe0 + (v >> 12); -- cgit v1.1