Skip to content

Commit e2e81da

Browse files
committed
...
1 parent 72b72aa commit e2e81da

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParser.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ protected final void _finishToken() throws IOException
18981898
_binaryValue = _read7BitBinaryWithLength();
18991899
return;
19001900
case 7: // binary, raw
1901-
_binaryValue = _finishRawBinary();
1901+
_binaryValue = _finishBinaryRaw();
19021902
return;
19031903
}
19041904
}
@@ -2441,14 +2441,16 @@ private final void _decodeLongUnicode() throws IOException
24412441
/**********************************************************************
24422442
*/
24432443

2444-
private final byte[] _finishRawBinary() throws IOException
2444+
// Helper method for reading complete binary data value from "raw"
2445+
// value (regular byte-per-byte)
2446+
private final byte[] _finishBinaryRaw() throws IOException
24452447
{
24462448
int byteLen = _readUnsignedVInt();
24472449

24482450
// 20-Mar-2021, tatu [dataformats-binary#260]: avoid eager allocation
24492451
// for very large content
24502452
if (byteLen > LONGEST_NON_CHUNKED_BINARY) {
2451-
return _finishRawBinaryLong(byteLen);
2453+
return _finishBinaryRawLong(byteLen);
24522454
}
24532455

24542456
// But use simpler, no intermediate buffering, for more compact cases
@@ -2478,7 +2480,7 @@ private final byte[] _finishRawBinary() throws IOException
24782480
}
24792481

24802482
// @since 2.12.3
2481-
protected byte[] _finishRawBinaryLong(final int expLen) throws IOException
2483+
protected byte[] _finishBinaryRawLong(final int expLen) throws IOException
24822484
{
24832485
int left = expLen;
24842486

@@ -2509,9 +2511,16 @@ protected byte[] _finishRawBinaryLong(final int expLen) throws IOException
25092511
private final byte[] _read7BitBinaryWithLength() throws IOException
25102512
{
25112513
int byteLen = _readUnsignedVInt();
2512-
byte[] result = new byte[byteLen];
2514+
2515+
// 20-Mar-2021, tatu [dataformats-binary#260]: avoid eager allocation
2516+
// for very large content
2517+
if (byteLen > LONGEST_NON_CHUNKED_BINARY) {
2518+
// return _finishBinary7BitLong(byteLen);
2519+
}
2520+
2521+
final byte[] result = new byte[byteLen];
2522+
final int lastOkPtr = byteLen - 7;
25132523
int ptr = 0;
2514-
int lastOkPtr = byteLen - 7;
25152524

25162525
// first, read all 7-by-8 byte chunks
25172526
while (ptr <= lastOkPtr) {
@@ -2555,10 +2564,16 @@ private final byte[] _read7BitBinaryWithLength() throws IOException
25552564
return result;
25562565
}
25572566

2567+
// @since 2.12.3
2568+
protected byte[] _finishBinary7BitLong(final int expLen) throws IOException
2569+
{
2570+
return null;
2571+
}
2572+
25582573
/*
2559-
/**********************************************************
2574+
/**********************************************************************
25602575
/* Internal methods, skipping
2561-
/**********************************************************
2576+
/**********************************************************************
25622577
*/
25632578

25642579
/**

0 commit comments

Comments
 (0)