Skip to content

Commit 1773cdb

Browse files
committed
Fixing invalid data access in unicode character mapping
1 parent f6d5127 commit 1773cdb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/inc/sys_string/impl/unicode/mappings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace sysstr::util
5252
m_mapped(mapped)
5353
{}
5454
template<utf_encoding Enc, class OutIt>
55-
auto write(char32_t c, OutIt dest) const noexcept(noexcept(*dest++ = utf_char_of<Enc>())) -> OutIt
55+
static auto write(char32_t c, OutIt dest) noexcept(noexcept(*dest++ = utf_char_of<Enc>())) -> OutIt
5656
{
5757
if constexpr (Enc == utf32)
5858
{
@@ -67,7 +67,7 @@ namespace sysstr::util
6767
}
6868
}
6969
template<utf_encoding Enc, class OutIt>
70-
auto write(const char16_t * begin, const char16_t * end, OutIt dest) const noexcept(noexcept(*dest++ = utf_char_of<Enc>())) -> OutIt
70+
static auto write(const char16_t * begin, const char16_t * end, OutIt dest) noexcept(noexcept(*dest++ = utf_char_of<Enc>())) -> OutIt
7171
{
7272
if constexpr (Enc == utf16)
7373
{
@@ -80,7 +80,7 @@ namespace sysstr::util
8080
{
8181
decoder.put(*begin++);
8282
if (!decoder.done())
83-
decoder.put(m_mapped[*begin++]); //no need to bounds check, we know end is good
83+
decoder.put(*begin++); //no need to bounds check, we know end is good
8484
dest = write<Enc>(decoder.value(), dest);
8585
}
8686
return dest;

test/test_general.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ TEST_CASE( "Case conversion", "[general]" ) {
233233
CHECK(S("ΑΣͺΑ").to_lower() == S("ασͺα"));
234234

235235
CHECK(S("βους").to_upper() == S("ΒΟΥΣ"));
236+
237+
CHECK(S("\U00010400").to_lower() == S("\U00010428"));
236238
}
237239

238240
TEST_CASE( "Trim", "[general]" ) {

0 commit comments

Comments
 (0)