int utf8s_to_utf16s(const u8 *s, int len, enum utf16_endian endian,
		wchar_t *pwcs, int maxlen)
{
	u16 *op;
	int size;
	unicode_t u;

	op = pwcs;
	while (len > 0 && maxlen > 0 && *s) {
		if (*s & 0x80) {
			size = utf8_to_utf32(s, len, &u);
			if (size < 0)
				return -EINVAL;
			s += size;
			len -= size;

			if (u >= PLANE_SIZE) {
				if (maxlen < 2)
					break;
				u -= PLANE_SIZE;
				put_utf16(op++, SURROGATE_PAIR |
						((u >> 10) & SURROGATE_BITS),
						endian);
				put_utf16(op++, SURROGATE_PAIR |
						SURROGATE_LOW |
						(u & SURROGATE_BITS),
						endian);
				maxlen -= 2;
			} else {
				put_utf16(op++, u, endian);
				maxlen--;
			}
		} else {
			put_utf16(op++, *s++, endian);
			len--;
			maxlen--;
		}
	}
	return op - pwcs;
}
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.