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> 2006-01-18 Andrew Ruder <aeruder@ksu.edu>
* config/addlibrarypath.m4: new file * config/addlibrarypath.m4: new file

View file

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