diff options
author | Marko Vojvodic <marko.vojvodic@mongodb.com> | 2016-11-17 15:18:36 -0500 |
---|---|---|
committer | Marko Vojvodic <marko.vojvodic@mongodb.com> | 2016-11-17 16:14:10 -0500 |
commit | 8ab19a65f361a2f0fed4d788368b296f42e43495 (patch) | |
tree | ec03d882d137cc7ff23e1c6a24c9d60fb6189b15 | |
parent | b7472174d000fa00db7827aeadb9fe17738ecfd9 (diff) | |
download | mongo-8ab19a65f361a2f0fed4d788368b296f42e43495.tar.gz |
SERVER-27097 Check that db is not null before derefencing in _collectionCount
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 6 |
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(); |