diff --git a/src/boson/bson_archiver.hpp b/src/boson/bson_archiver.hpp index e590cb4..8f50a0d 100644 --- a/src/boson/bson_archiver.hpp +++ b/src/boson/bson_archiver.hpp @@ -394,7 +394,8 @@ class BSONOutputArchive : public cereal::OutputArchive { } 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. diff --git a/src/boson/bson_streambuf.cpp b/src/boson/bson_streambuf.cpp index ce18da7..afad1da 100644 --- a/src/boson/bson_streambuf.cpp +++ b/src/boson/bson_streambuf.cpp @@ -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) { _cb({std::move(_data), _len}); _bytes_read = 0; _len = 0;