diff options
author | Kristina <kristina@10gen.com> | 2012-11-06 17:43:56 -0500 |
---|---|---|
committer | Kristina <kristina@10gen.com> | 2012-11-06 17:43:56 -0500 |
commit | ea86be562f0d91a60e1df033a3710d98a78ef801 (patch) | |
tree | 0b0f9acdc7d9c9ad1d12bd3b513100814ea2557d | |
parent | d7fe5dc2d8f0cf6a95064bfe1ec457e8c4f66a9f (diff) | |
download | mongo-ea86be562f0d91a60e1df033a3710d98a78ef801.tar.gz |
SERVER-7498 Check config is not null before dereferencing
-rw-r--r-- | src/mongo/db/repl/rs_initialsync.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp index cd11482ed9a..df37b96b08f 100644 --- a/src/mongo/db/repl/rs_initialsync.cpp +++ b/src/mongo/db/repl/rs_initialsync.cpp @@ -138,6 +138,8 @@ namespace mongo { return target; } + Member* primary = const_cast<Member*>(box.getPrimary()); + // wait for 2N pings before choosing a sync target if (_cfg) { int needMorePings = config().members.size()*2 - HeartbeatInfo::numPings; @@ -148,14 +150,12 @@ namespace mongo { } buildIndexes = myConfig().buildIndexes; - } - Member* primary = const_cast<Member*>(box.getPrimary()); - - // If we are only allowed to sync from the primary, return that - if (!config().chainingAllowed()) { - // Returns NULL if we cannot reach the primary - return primary; + // If we are only allowed to sync from the primary, return that + if (!_cfg->chainingAllowed()) { + // Returns NULL if we cannot reach the primary + return primary; + } } // find the member with the lowest ping time that has more data than me |