From 32d24c4fca2b3b36261337106df398f1a757efe5 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Mon, 21 Jan 2008 22:53:55 +0000 Subject: [PATCH] ICU-6151 Add out of bound check for target CharBuffer in decodeLoop. X-SVN-Rev: 23283 --- icu4j/src/com/ibm/icu/charset/CharsetUTF7.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/icu4j/src/com/ibm/icu/charset/CharsetUTF7.java b/icu4j/src/com/ibm/icu/charset/CharsetUTF7.java index aa376f1c354..63503e410fb 100644 --- a/icu4j/src/com/ibm/icu/charset/CharsetUTF7.java +++ b/icu4j/src/com/ibm/icu/charset/CharsetUTF7.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 2007, International Business Machines Corporation and * + * Copyright (C) 2007-2008, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -235,9 +235,13 @@ class CharsetUTF7 extends CharsetICU { break; } else if ((!useIMAP && b!=PLUS) || (useIMAP && b!=AMPERSAND)) { // write directly encoded character - target.put(b); - if (offsets!= null) { - offsets.put(sourceIndex++); + if (target.hasRemaining()) { // Check to make sure that there is room in target. + target.put(b); + if (offsets!= null) { + offsets.put(sourceIndex++); + } + } else { // Get out and set the CoderResult. + break; } } else { /* PLUS or (AMPERSAND in IMAP)*/ /* switch to Unicode mode */