Skip to content

Commit

Permalink
SERVER-7498 Check config is not null before dereferencing
Browse files Browse the repository at this point in the history
  • Loading branch information
kchodorow committed Nov 6, 2012
1 parent d7fe5dc commit ea86be5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/mongo/db/repl/rs_initialsync.cpp
Expand Up @@ -138,6 +138,8 @@ namespace mongo {
return target; return target;
} }


Member* primary = const_cast<Member*>(box.getPrimary());

// wait for 2N pings before choosing a sync target // wait for 2N pings before choosing a sync target
if (_cfg) { if (_cfg) {
int needMorePings = config().members.size()*2 - HeartbeatInfo::numPings; int needMorePings = config().members.size()*2 - HeartbeatInfo::numPings;
Expand All @@ -148,14 +150,12 @@ namespace mongo {
} }


buildIndexes = myConfig().buildIndexes; buildIndexes = myConfig().buildIndexes;
}


Member* primary = const_cast<Member*>(box.getPrimary()); // If we are only allowed to sync from the primary, return that

if (!_cfg->chainingAllowed()) {
// If we are only allowed to sync from the primary, return that // Returns NULL if we cannot reach the primary
if (!config().chainingAllowed()) { return primary;
// Returns NULL if we cannot reach the primary }
return primary;
} }


// find the member with the lowest ping time that has more data than me // find the member with the lowest ping time that has more data than me
Expand Down

0 comments on commit ea86be5

Please sign in to comment.