ICU-6612 Use buffer.limit() instead of buffer.capacity() to avoid BufferOverflow execptions in CharsetMBCS.

X-SVN-Rev: 24928
This commit is contained in:
Michael Ow 2008-11-04 21:43:48 +00:00
parent 46fb1b9b1f
commit 5bbad7ac78

View File

@ -2684,7 +2684,7 @@ class CharsetMBCS extends CharsetICU {
}
}
if (!cr[0].isError() && sourceArrayIndex < source.capacity() && !target.hasRemaining()) {
if (!cr[0].isError() && sourceArrayIndex < source.limit() && !target.hasRemaining()) {
/* target is full */
cr[0] = CoderResult.OVERFLOW;
}
@ -2991,7 +2991,7 @@ class CharsetMBCS extends CharsetICU {
/* try an extension mapping */
if (sharedData.mbcs.extIndexes != null) {
/* Increase the limit for proper handling. Used in LMBCS. */
if (source.capacity() >= source.position() + length) {
if (source.limit() >= source.position() + length) {
source.limit(source.position() + length);
}
return simpleMatchToU(source, useFallback);