diff options
author | Narayan Kamath <narayan@google.com> | 2014-11-26 13:05:57 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-11-26 13:11:40 +0000 |
commit | c0c629a18d45985ef73a90b5440da1f087177d46 (patch) | |
tree | 9cf17c8f49d49b5ccda5151f48ed6fc8db87a805 /luni | |
parent | 6ff0bc557127f5ee1300549ab5b2867ff19a1944 (diff) | |
download | libcore-c0c629a18d45985ef73a90b5440da1f087177d46.zip libcore-c0c629a18d45985ef73a90b5440da1f087177d46.tar.gz libcore-c0c629a18d45985ef73a90b5440da1f087177d46.tar.bz2 |
Fix CharsetEncoder.canEncode for ignorable code points.
We should check that the output buffer has at least a single
byte.
bug: 18474439
Change-Id: Iec8042f54133c77d962ed2c5c5ace25a8ce6dad2
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/java/java/nio/charset/CharsetEncoder.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/luni/src/main/java/java/nio/charset/CharsetEncoder.java b/luni/src/main/java/java/nio/charset/CharsetEncoder.java index 9217bba..84373c5 100644 --- a/luni/src/main/java/java/nio/charset/CharsetEncoder.java +++ b/luni/src/main/java/java/nio/charset/CharsetEncoder.java @@ -199,8 +199,10 @@ public abstract class CharsetEncoder { onMalformedInput(CodingErrorAction.REPORT); onUnmappableCharacter(CodingErrorAction.REPORT); try { - encode(cb); - return true; + ByteBuffer buf = encode(cb); + // b/18474439: ICU will return U_ZERO_ERROR but produce an output buffer + // of size zero when it encounters an ignorable codepoint. + return buf.hasRemaining(); } catch (CharacterCodingException e) { return false; } finally { |