Permalink
Browse files

SERVER-7498 Check config is not null before dereferencing

  • Loading branch information...
1 parent d7fe5dc commit ea86be562f0d91a60e1df033a3710d98a78ef801 @kchodorow kchodorow committed Nov 6, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 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

0 comments on commit ea86be5

Please sign in to comment.