diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2018-03-30 14:12:58 -0400 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2018-04-02 11:23:41 -0400 |
commit | c22357338a6f192deb3e24e2a07672419cc7dacb (patch) | |
tree | 9501de18359e04843027927ee73a7283f5226ef4 /src/mongo/db/field_ref.cpp | |
parent | d4629daf3c3a024415ca2ddff9234b8455d5b19b (diff) | |
download | mongo-c22357338a6f192deb3e24e2a07672419cc7dacb.tar.gz |
SERVER-34218 Always reinitialize fields in FieldRef::parse().
Previously, calling FieldRef::FieldRef(StringData) never initialized
_cachedSize, resulting in unpredictable build failures.
Additionally, calling FieldRef::parse(StringData) with the empty
string did not reinitialize the FieldRef.
Diffstat (limited to 'src/mongo/db/field_ref.cpp')
-rw-r--r-- | src/mongo/db/field_ref.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mongo/db/field_ref.cpp b/src/mongo/db/field_ref.cpp index 3a759febe3c..3070aafebb3 100644 --- a/src/mongo/db/field_ref.cpp +++ b/src/mongo/db/field_ref.cpp @@ -38,19 +38,17 @@ const size_t FieldRef::kReserveAhead; FieldRef::FieldRef() : _size(0), _cachedSize(0) {} -FieldRef::FieldRef(StringData path) : _size(0) { +FieldRef::FieldRef(StringData path) { parse(path); } void FieldRef::parse(StringData path) { + clear(); + if (path.size() == 0) { return; } - if (_size != 0) { - clear(); - } - // We guarantee that accesses through getPart() will be valid while 'this' is. So we // keep a copy in a local sting. |