summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2008-01-25 13:43:50 +0000
committerpixel <pixel>2008-01-25 13:43:50 +0000
commit6dff2a525e47b71ce11c505b444a1123f5c77ccd (patch)
treed07d889d5db3a9fb02d552cb3ecff42659457832
parentdf9c76bcd6d112367cdc72402e6b39d1d858e17c (diff)
Fixing and patching iconv.
-rw-r--r--lib/String.cc11
1 files changed, 8 insertions, 3 deletions
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 <stdio.h>
#include <string.h>
@@ -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);