summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Vojvodic <marko.vojvodic@mongodb.com>2016-11-17 15:18:36 -0500
committerMarko Vojvodic <marko.vojvodic@mongodb.com>2016-11-17 16:14:10 -0500
commit8ab19a65f361a2f0fed4d788368b296f42e43495 (patch)
treeec03d882d137cc7ff23e1c6a24c9d60fb6189b15
parentb7472174d000fa00db7827aeadb9fe17738ecfd9 (diff)
downloadmongo-8ab19a65f361a2f0fed4d788368b296f42e43495.tar.gz
SERVER-27097 Check that db is not null before derefencing in _collectionCount
-rw-r--r--src/mongo/db/commands/mr.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index c113a8afe63..cb65aec0486 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -608,14 +608,16 @@ namespace {
unsigned long long _collectionCount(OperationContext* txn,
const string& ns,
bool callerHoldsGlobalLock) {
- Collection* coll;
+ Collection* coll = nullptr;
boost::optional<AutoGetCollectionForRead> ctx;
// If the global write lock is held, we must avoid using AutoGetCollectionForRead as it may lead
// to deadlock when waiting for a majority snapshot to be committed. See SERVER-24596.
if (callerHoldsGlobalLock) {
Database* db = dbHolder().get(txn, ns);
- coll = db->getCollection(ns);
+ if (db) {
+ coll = db->getCollection(ns);
+ }
} else {
ctx.emplace(txn, NamespaceString(ns));
coll = ctx->getCollection();