Handle overlapping buffers properly in wcstombs_sbcs (spotted by

Dmitry Timoshkov).
This commit is contained in:
Alexandre Julliard 2003-05-11 02:54:09 +00:00
parent 34a148685e
commit 794b130cbb

View file

@ -143,6 +143,17 @@ static inline int wcstombs_sbcs( const struct sbcs_table *table,
ret = -1; ret = -1;
} }
if (dst <= (char *)src && dst + 16 > (char *)src)
{
/* overlapping buffers, do it char by char */
while (srclen--)
{
*dst++ = uni2cp_low[uni2cp_high[*src >> 8] + (*src & 0xff)];
src++;
}
return ret;
}
for (;;) for (;;)
{ {
switch(srclen) switch(srclen)