Index: src/OFMutableString_UTF8.m ================================================================== --- src/OFMutableString_UTF8.m +++ src/OFMutableString_UTF8.m @@ -205,11 +205,11 @@ if (_s->isUTF8) idx = of_string_utf8_get_position(_s->cString, idx, _s->cStringLength); - if (idx > _s->cStringLength) + if (idx >= _s->cStringLength) @throw [OFOutOfRangeException exception]; /* Shortcut if old and new character both are ASCII */ if (character < 0x80 && !(_s->cString[idx] & 0x80)) { _s->hashed = false; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -263,11 +263,11 @@ } ssize_t of_string_utf8_decode(const char *buffer_, size_t length, of_unichar_t *ret) { - const uint8_t *buffer = (const uint8_t *)buffer_; + const unsigned char *buffer = (const unsigned char *)buffer_; if (!(*buffer & 0x80)) { *ret = buffer[0]; return 1; } Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -165,11 +165,11 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length) { for (size_t i = 0; i <= idx; i++) if OF_UNLIKELY ((string[i] & 0xC0) == 0x80) if (++idx > length) - return OF_NOT_FOUND; + @throw [OFInvalidFormatException exception]; return idx; } @implementation OFString_UTF8 Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -91,12 +91,12 @@ # define OF_CONST_FUNC __attribute__((__const__)) # define OF_NO_RETURN_FUNC __attribute__((__noreturn__)) # define OF_WEAK_REF(sym) __attribute__((__weakref__(sym))) #else # define OF_INLINE inline -# define OF_LIKELY(cond) cond -# define OF_UNLIKELY(cond) cond +# define OF_LIKELY(cond) (cond) +# define OF_UNLIKELY(cond) (cond) # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC # define OF_WEAK_REF(sym) #endif