Skip to content

Commit 01492c0

Browse files
dtreffilettiacmorrow
authored andcommitted
CXX-1426 Check cursor pointers before to use them
Some check where missing from the commit: CXX-229 check cursor pointers before internally iterating Signed-off-by: Andrew Morrow <[email protected]>
1 parent be5724e commit 01492c0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/mongo/client/dbclient.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,9 +1527,12 @@ auto_ptr<DBClientCursor> DBClientWithCommands::_legacyCollectionInfo(const strin
15271527
auto_ptr<DBClientCursor> simple =
15281528
query(namespaces_ns, fallbackFilter.obj(), 0, 0, 0, QueryOption_SlaveOk, batchSize);
15291529

1530-
simple->shim.reset(new DBClientCursorShimTransform(*simple, transformLegacyCollectionInfos));
1531-
simple->nToReturn = 0;
1532-
simple->setBatchSize(batchSize);
1530+
if (simple.get()) {
1531+
simple->shim.reset(
1532+
new DBClientCursorShimTransform(*simple, transformLegacyCollectionInfos));
1533+
simple->nToReturn = 0;
1534+
simple->setBatchSize(batchSize);
1535+
}
15331536

15341537
return simple;
15351538
}
@@ -1925,8 +1928,10 @@ std::auto_ptr<DBClientCursor> DBClientBase::aggregate(const std::string& ns,
19251928
queryOptions,
19261929
0);
19271930

1928-
simple->shim.reset(new DBClientCursorShimArray(*simple, "result"));
1929-
simple->nToReturn = 0;
1931+
if (simple.get()) {
1932+
simple->shim.reset(new DBClientCursorShimArray(*simple, "result"));
1933+
simple->nToReturn = 0;
1934+
}
19301935

19311936
return simple;
19321937
}

0 commit comments

Comments
 (0)