Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit ee746dc

Browse files
committed
Fix #18, starting 2.5.x backport
1 parent f034c1a commit ee746dc

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

release-notes/VERSION

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Project: jackson-dataformat-cbor
44
=== Releases ===
55
------------------------------------------------------------------------
66

7+
2.5.6 (not released)
8+
9+
#18: Correct parsing of zero length byte strings
10+
(reported, fix suggested by philipa@github)
11+
712
2.5.5 (07-Dec-2015)
813
2.5.4 (09-Jun-2015)
914
2.5.3 (24-Apr-2015)

src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
public final class CBORParser extends ParserMinimalBase
2020
{
21+
private final static byte[] NO_BYTES = new byte[0];
22+
2123
/**
2224
* Enumeration that defines all togglable features for CBOR generators.
2325
*/
@@ -1726,6 +1728,9 @@ protected byte[] _finishBytes(int len) throws IOException
17261728
{
17271729
// First, simple: non-chunked
17281730
if (len >= 0) {
1731+
if (len == 0) {
1732+
return NO_BYTES;
1733+
}
17291734
byte[] b = new byte[len];
17301735
if (_inputPtr >= _inputEnd) {
17311736
loadMoreGuaranteed();

src/test/java/com/fasterxml/jackson/dataformat/cbor/ParserBinaryTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public Bytes() { }
2020
private final ObjectMapper MAPPER = cborMapper();
2121

2222
public void testSmallBinaryValues() throws Exception {
23+
_testBinary(0);
2324
_testBinary(1);
2425
_testBinary(20);
2526
_testBinary(100);

0 commit comments

Comments
 (0)