From 92766280403a3984002801cde531362b8696fdec Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Wed, 18 Jan 2006 14:19:47 +0000 Subject: [PATCH] Quick unicode fix git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22328 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/Additions/Unicode.m | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66c71a3a3..23d3c1506 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-18 Richard Frith-Macdonald + + * Source/Additions/Unicode.m: fix for rare case where we could corrupt + the stack ... spotted by Wim Oudshoorn. + 2006-01-18 Andrew Ruder * config/addlibrarypath.m4: new file diff --git a/Source/Additions/Unicode.m b/Source/Additions/Unicode.m index a77dbab19..f470c9981 100644 --- a/Source/Additions/Unicode.m +++ b/Source/Additions/Unicode.m @@ -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) - { - GROW(); - } - if (sl == 1) { + if (dpos >= bsize) + { + GROW(); + } 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; } }