This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
Patch: \0-termination for iconv
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: \0-termination for iconv
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 05 Oct 2000 15:38:12 -0600
- Reply-To: tromey at cygnus dot com
I'm checking in this patch. It fixes a simple bug in the iconv
converter.
2000-10-05 Tom Tromey <tromey@cygnus.com>
* gnu/gcj/convert/natIconv.cc (init): Terminate buffer.
Tom
Index: gnu/gcj/convert/natIconv.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/gnu/gcj/convert/natIconv.cc,v
retrieving revision 1.6
diff -u -r1.6 natIconv.cc
--- natIconv.cc 2000/09/05 11:05:58 1.6
+++ natIconv.cc 2000/10/05 21:31:09
@@ -38,8 +38,9 @@
{
#ifdef HAVE_ICONV
jsize len = _Jv_GetStringUTFLength (encoding);
- char buffer[len];
+ char buffer[len + 1];
_Jv_GetStringUTFRegion (encoding, 0, len, buffer);
+ buffer[len] = '\0';
iconv_t h = iconv_open ("UCS-2", buffer);
if (h == (iconv_t) -1)
@@ -97,8 +98,9 @@
{
#ifdef HAVE_ICONV
jsize len = _Jv_GetStringUTFLength (encoding);
- char buffer[len];
+ char buffer[len + 1];
_Jv_GetStringUTFRegion (encoding, 0, len, buffer);
+ buffer[len] = '\0';
iconv_t h = iconv_open (buffer, "UCS-2");
if (h == (iconv_t) -1)