memcpy(), which is what Copy() resolves to, is not supposed to handle
the possibility of overlapping source and destination. In some cases
in this code, the source and destination pointers are identical. What
should happen then is a no-op, so just don't do the copy in that case.
If the ptrs aren't identical, they won't otherwise overlap, so the
Copy() is valid except for when they are identical.
/* Here, there was no mapping defined, which means that the code point maps
* to itself. Return the inputs */
len = UTF8SKIP(p);
- Copy(p, ustrp, len, U8);
+ if (p != ustrp) { /* Don't copy onto itself */
+ Copy(p, ustrp, len, U8);
+ }
if (lenp)
*lenp = len;