summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bson/bsonobjiterator.h2
-rw-r--r--db/clientcursor.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/bson/bsonobjiterator.h b/bson/bsonobjiterator.h
index 69958cb6331..0d2344e002e 100644
--- a/bson/bsonobjiterator.h
+++ b/bson/bsonobjiterator.h
@@ -26,6 +26,8 @@ namespace mongo {
Note each BSONObj ends with an EOO element: so you will get more() on an empty
object, although next().eoo() will be true.
+ The BSONObj must stay in scope for the duration of the iterator's execution.
+
todo: we may want to make a more stl-like iterator interface for this
with things like begin() and end()
*/
diff --git a/db/clientcursor.cpp b/db/clientcursor.cpp
index 81c82fca4d1..8a415c12a8c 100644
--- a/db/clientcursor.cpp
+++ b/db/clientcursor.cpp
@@ -346,7 +346,8 @@ namespace mongo {
int x = i->second;
- BSONObjIterator it( currKey() );
+ BSONObj ck = currKey();
+ BSONObjIterator it( ck );
while ( x && it.more() ) {
it.next();
x--;