This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: \0-termination for iconv


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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]