summaryrefslogtreecommitdiff
path: root/src/mongo/db/field_ref.cpp
diff options
context:
space:
mode:
authorAndrew Morrow <acm@10gen.com>2013-09-25 18:21:15 -0400
committerAndrew Morrow <acm@10gen.com>2013-09-25 19:11:43 -0400
commit7f9402ad7a5d5c741636f04ce1dbdf48b076d65a (patch)
treec0b753a969c32b0eb2bd651c5e315a58061a8fd6 /src/mongo/db/field_ref.cpp
parent602fa4c70120da815d93014773eee0454076a7d9 (diff)
downloadmongo-7f9402ad7a5d5c741636f04ce1dbdf48b076d65a.tar.gz
SERVER-10159 Avoid forming past end iterator when reserializing
Diffstat (limited to 'src/mongo/db/field_ref.cpp')
-rw-r--r--src/mongo/db/field_ref.cpp8
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