Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -99,10 +99,16 @@ /* We're missing a start byte here */ if (OF_UNLIKELY(!(string[i] & 0x40))) { madvise((void*)string, length, MADV_NORMAL); return -1; } + + /* 2 byte sequences for code points 0 - 127 are forbidden */ + if (OF_UNLIKELY((string[i] & 0x7E) == 0x40)) { + madvise((void*)string, length, MADV_NORMAL); + return -1; + } /* We have at minimum a 2 byte character -> check next byte */ if (OF_UNLIKELY(length <= i + 1 || (string[i + 1] & 0xC0) != 0x80)) { madvise((void*)string, length, MADV_NORMAL);