[kaffe] kaffe.io.ByteToCharIconv may go in to an endless loop
Ito Kazumitsu
ito.kazumitsu at hitachi-cable.co.jp
Wed Nov 20 16:27:45 PST 2002
In message "Re: [kaffe] kaffe.io.ByteToCharIconv may go in to an endless loop"
on 02/11/21, Ito Kazumitsu <ito.kazumitsu at hitachi-cable.co.jp> writes:
> > and found that in the abnormal cases "carry" is called endlessly.
>
> Here is a patch to solve this problem.
The following patch would better simulate JDK's behavior.
--- libraries/clib/native/ByteToCharIconv.c.orig Tue Apr 16 04:14:50 2002
+++ libraries/clib/native/ByteToCharIconv.c Thu Nov 21 09:16:34 2002
@@ -89,6 +89,16 @@
icv_out = buffer;
#endif
ret = iconv (cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
+ if (ret < 0) {
+ /* convert the begining of an invalid multibyte sequence to '?' */
+ if (errno == EILSEQ) {
+ icv_in++;
+ icv_inlen--;
+ *(icv_out++) = 0;
+ *(icv_out++) = '?';
+ icv_outlen -= 2;
+ }
+ }
#ifndef WORDS_BIGENDIAN
swab (buffer, jc + toPos, toLen * 2 - icv_outlen);
KFREE (buffer);
More information about the kaffe
mailing list