Skip to content

Fix mangrove crash #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/boson/bson_archiver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ class BSONOutputArchive : public cereal::OutputArchive<BSONOutputArchive> {
} else {
// Set the key of this element to the name stored by the archiver.
if (!_dotNotationMode || _embeddedNameStack.empty() || _arrayNestingLevel > 0) {
_bsonBuilder.key_view(_nextName);
if (!isNewNode || !_dotNotationMode)
_bsonBuilder.key_view(_nextName);
} else {
// If we are in dot notation mode and we're not nested in array, build the name of
// this key.
Expand Down
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