From 6dff2a525e47b71ce11c505b444a1123f5c77ccd Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 25 Jan 2008 13:43:50 +0000 Subject: Fixing and patching iconv. --- lib/String.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/String.cc b/lib/String.cc index 529a8dd..3d13efd 100644 --- a/lib/String.cc +++ b/lib/String.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: String.cc,v 1.49 2008-01-25 10:09:19 pixel Exp $ */ +/* $Id: String.cc,v 1.50 2008-01-25 13:43:50 pixel Exp $ */ #include #include @@ -595,9 +595,14 @@ String & String::iconv(const String & from, const String & _to) { ::iconv (cd, &inbuf, &inleft, &outbuf, &outleft); free(str); + + siz = outbuf - t; - str = (char *) malloc(outbuf - t + 1); - memcpy(str, t, outbuf - t); + // let's pad up to 2 bytes in order to be safe with wchar_t's + str = (char *) malloc(siz + 2); + memcpy(str, t, siz); + str[siz] = 0; + str[siz + 1] = 0; UNLOCK; iconv_close(cd); -- cgit v1.2.3