Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/boson/bson_streambuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int bson_output_streambuf::insert(int ch) {
}

// This creates the document from the given bytes, and calls the user-provided callback.
if (_bytes_read == _len) {
if (_bytes_read == _len && _len > 4) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about earlier(e..g line 54) just returning early if _bytes_read < 4, so we're never dealing with an invalid _len in the later code?

_cb({std::move(_data), _len});
_bytes_read = 0;
_len = 0;
Expand Down