Quick unicode fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22328 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2006-01-18 14:19:47 +00:00
parent c6777b1cc3
commit 5e2d547f94
2 changed files with 17 additions and 6 deletions

View file

@ -1,3 +1,8 @@
2006-01-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/Unicode.m: fix for rare case where we could corrupt
the stack ... spotted by Wim Oudshoorn.
2006-01-18 Andrew Ruder <aeruder@ksu.edu>
* config/addlibrarypath.m4: new file

View file

@ -1837,14 +1837,12 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
sl = 6;
}
/* make sure we have enough space for it */
while (dpos + sl >= bsize)
if (sl == 1)
{
if (dpos >= bsize)
{
GROW();
}
if (sl == 1)
{
ptr[dpos++] = u & 0x7f;
}
else
@ -1859,10 +1857,18 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
u = u >> 6;
}
if (dpos >= bsize)
{
GROW();
}
ptr[dpos++] = reversed[sl-1] | ((0xff << (8-sl)) & 0xff);
/* add bytes into the output sequence */
for (i = sl - 2; i >= 0; i--)
{
if (dpos >= bsize)
{
GROW();
}
ptr[dpos++] = reversed[i] | 0x80;
}
}