FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix #391: Add missing buffer null check by xerial · Pull Request #392 · msgpack/msgpack-java · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) .scala  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,9 @@ public MessagePacker writePayload(byte[] src)
public MessagePacker writePayload(byte[] src, int off, int len)
throws IOException
{
if (buffer.size() - position < len || len > bufferFlushThreshold) {
if (buffer == null || buffer.size() - position < len || len > bufferFlushThreshold) {
flush(); // call flush before write
// Directly write payload to the output without using the buffer
out.write(src, off, len);
totalFlushBytes += len;
}
Expand Down Expand Up @@ -770,8 +771,9 @@ public MessagePacker addPayload(byte[] src)
public MessagePacker addPayload(byte[] src, int off, int len)
throws IOException
{
if (buffer.size() - position < len || len > bufferFlushThreshold) {
if (buffer == null || buffer.size() - position < len || len > bufferFlushThreshold) {
flush(); // call flush before add
// Directly add the payload without using the buffer
out.add(src, off, len);
totalFlushBytes += len;
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,17 @@ class MessagePackerTest extends MessagePackSpec {
val s = unpacker.unpackString()
s shouldBe "small string"
}

"write raw binary" taggedAs("raw-binary") in {
val packer = new MessagePack.PackerConfig().newBufferPacker()
val msg = Array[Byte](-127, -92, 116, 121, 112, 101, -92, 112, 105, 110, 103)
packer.writePayload(msg)
}

"append raw binary" taggedAs("append-raw-binary") in {
val packer = new MessagePack.PackerConfig().newBufferPacker()
val msg = Array[Byte](-127, -92, 116, 121, 112, 101, -92, 112, 105, 110, 103)
packer.addPayload(msg)
}

}

Back | FazBrowse Home | New Git URL