diff options
author | Tad Marshall <tad@10gen.com> | 2012-12-08 14:50:16 -0500 |
---|---|---|
committer | Tad Marshall <tad@10gen.com> | 2012-12-08 14:55:59 -0500 |
commit | be0a3384012985ed2f8b0b568b93628bcb0c2ec8 (patch) | |
tree | 0af8afeceb0d6f4773a0841fb1843cbc3db85d0f /src | |
parent | c5b21478da310c15fca13f1b69e93e83418796ea (diff) | |
download | mongo-be0a3384012985ed2f8b0b568b93628bcb0c2ec8.tar.gz |
SERVER-7865 Make copy of resultSet to be owned by mock cursor
Store a copy of the result set returned by a mock query in the
MockDBClientCursor so that the data is not freed when the temporaries
go out of scope. The copy will be freed when the MockDBClientCursor
is destroyed.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/dbtests/mock/mock_dbclient_cursor.cpp | 3 | ||||
-rw-r--r-- | src/mongo/dbtests/mock/mock_dbclient_cursor.h | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/mongo/dbtests/mock/mock_dbclient_cursor.cpp b/src/mongo/dbtests/mock/mock_dbclient_cursor.cpp index 642d2bc0535..d141aeae1bb 100644 --- a/src/mongo/dbtests/mock/mock_dbclient_cursor.cpp +++ b/src/mongo/dbtests/mock/mock_dbclient_cursor.cpp @@ -21,7 +21,8 @@ namespace mongo { MockDBClientCursor::MockDBClientCursor(mongo::DBClientBase* client, const mongo::BSONArray& resultSet): mongo::DBClientCursor(client, "", 0, 0, 0) { - _cursor.reset(new mongo::DBClientMockCursor(BSONArray(resultSet.copy()))); + _resultSet = resultSet.copy(); + _cursor.reset(new mongo::DBClientMockCursor(BSONArray(_resultSet))); } bool MockDBClientCursor::more() { diff --git a/src/mongo/dbtests/mock/mock_dbclient_cursor.h b/src/mongo/dbtests/mock/mock_dbclient_cursor.h index 463c0be016b..454a2a61288 100644 --- a/src/mongo/dbtests/mock/mock_dbclient_cursor.h +++ b/src/mongo/dbtests/mock/mock_dbclient_cursor.h @@ -36,5 +36,6 @@ namespace mongo { private: boost::scoped_ptr<mongo::DBClientMockCursor> _cursor; + mongo::BSONObj _resultSet; }; } |