diff --git a/Engine/utility/textcodec.cpp b/Engine/utility/textcodec.cpp index 9239ca63..449c13e3 100644 --- a/Engine/utility/textcodec.cpp +++ b/Engine/utility/textcodec.cpp @@ -43,6 +43,8 @@ std::u16string TextCodec::toUtf16(std::string_view inS) { for(size_t i=0; i 0xFFFF) sz+=2; else diff --git a/Tests/tests/textcodec_test.cpp b/Tests/tests/textcodec_test.cpp index ef84213e..dfafc10b 100644 --- a/Tests/tests/textcodec_test.cpp +++ b/Tests/tests/textcodec_test.cpp @@ -56,3 +56,8 @@ TEST(main,TextCodec_UTF8_4) { TextCodec_Base(u8,u16); } + +TEST(main,TextCodec_UTF8_invalid) { + std::string u8 = "\340\214\244\276m\177\000\000\200\002\000\000h\001\000"; + EXPECT_ANY_THROW(TextCodec::toUtf16(u8)); + }