summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/s/cluster_client_internal.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/s/cluster_client_internal.cpp b/src/mongo/s/cluster_client_internal.cpp
index a5670926d2b..f24aaab4411 100644
--- a/src/mongo/s/cluster_client_internal.cpp
+++ b/src/mongo/s/cluster_client_internal.cpp
@@ -221,7 +221,8 @@ namespace mongo {
BSONObj collDoc = cursor->nextSafe();
- CollectionType* coll = new CollectionType();
+ // Replace with unique_ptr (also owned ptr map goes away)
+ auto_ptr<CollectionType> coll(new CollectionType());
string errMsg;
coll->parseBSON(collDoc, &errMsg);
@@ -245,8 +246,10 @@ namespace mongo {
if (optionalEpochs && epochNotSet) {
coll->setEpoch(OID());
}
-
- collections->mutableMap().insert(make_pair(coll->getNS(), coll));
+
+ // Get NS before releasing
+ string ns = coll->getNS();
+ collections->mutableMap().insert(make_pair(ns, coll.release()));
}
}
catch (const DBException& e) {
@@ -286,7 +289,8 @@ namespace mongo {
BSONObj chunkDoc = cursor->nextSafe();
- ChunkType* chunk = new ChunkType();
+ // TODO: replace with unique_ptr when available
+ auto_ptr<ChunkType> chunk(new ChunkType());
string errMsg;
if (!chunk->parseBSON(chunkDoc, &errMsg) || !chunk->isValid(&errMsg)) {
connPtr->done();
@@ -295,7 +299,7 @@ namespace mongo {
<< " read from the config server" << causedBy(errMsg));
}
- chunks->mutableVector().push_back(chunk);
+ chunks->mutableVector().push_back(chunk.release());
}
}
catch (const DBException& e) {