Skip to content

Commit

Permalink
Fixed potential crasher in VersionedDocument
Browse files Browse the repository at this point in the history
_docType wasn't being allocated on the heap, instead it just pointed
inside the doc's metadata. This caused it to be invalidated if the
metadata block got moved in memory when resized.

I haven't seen an actual crash from this, but the Xcode address sanitizer
caught it while purging docs in a unit test.
  • Loading branch information
snej committed Mar 30, 2016
1 parent cba8a28 commit f0f070a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CBForest/VersionedDocument.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ namespace cbforest {
_unknown = true; // i.e. doc was read as meta-only

if (_doc.exists()) {
if (!readMeta(_doc, _flags, _revID, _docType))
slice docType;
if (!readMeta(_doc, _flags, _revID, docType))
throw error(error::CorruptRevisionData);
_docType = docType; // allocate buf for it
} else {
_flags = 0;
}
Expand Down

0 comments on commit f0f070a

Please sign in to comment.