@@ -128,20 +128,18 @@ /* Look if there's a newline or \0 */ for (i = 0; i < len; i++) { if (OF_UNLIKELY(tmp[i] == '\n' || tmp[i] == '\0')) { @try { ret_c = [self - allocMemoryWithSize: cache_len + - i + 1]; + allocMemoryWithSize: cache_len + i]; } @catch (OFException *e) { [self freeMemory: tmp]; @throw e; } if (cache != NULL) memcpy(ret_c, cache, cache_len); memcpy(ret_c + cache_len, tmp, i); - ret_c[cache_len + i] = '\0'; if (i < len) { @try { tmp2 = [self allocMemoryWithSize: len - @@ -166,11 +164,12 @@ [self freeMemory: tmp]; @try { ret = [OFString stringWithCString: ret_c - encoding: encoding]; + encoding: encoding + length: cache_len + i]; } @finally { [self freeMemory: ret_c]; } return ret; }