diff options
author | Andrew Morrow <acm@10gen.com> | 2013-09-25 18:21:15 -0400 |
---|---|---|
committer | Andrew Morrow <acm@10gen.com> | 2013-09-25 19:11:43 -0400 |
commit | 7f9402ad7a5d5c741636f04ce1dbdf48b076d65a (patch) | |
tree | c0b753a969c32b0eb2bd651c5e315a58061a8fd6 | |
parent | 602fa4c70120da815d93014773eee0454076a7d9 (diff) | |
download | mongo-7f9402ad7a5d5c741636f04ce1dbdf48b076d65a.tar.gz |
SERVER-10159 Avoid forming past end iterator when reserializing
-rw-r--r-- | src/mongo/db/field_ref.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/db/field_ref.cpp b/src/mongo/db/field_ref.cpp index 15a1ed8c19f..2e6ce7f3b0f 100644 --- a/src/mongo/db/field_ref.cpp +++ b/src/mongo/db/field_ref.cpp @@ -128,11 +128,17 @@ namespace mongo { // Fixup the parts to refer to the new string std::string::const_iterator where = _dotted.begin(); + const std::string::const_iterator end = _dotted.end(); for (size_t i = 0; i != _size; ++i) { StringData& part = (i < kReserveAhead) ? _fixed[i] : _variable[getIndex(i)]; const size_t size = part.size(); part = StringData(&*where, size); - where += (size + 1); // account for '.' + where += size; + // skip over '.' unless we are at the end. + if (where != end) { + dassert(*where == '.'); + ++where; + } } // Drop any replacements |