Skip to content

Commit

Permalink
don't crash when url is not valid jeromelebel/MongoHub-Mac#196
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Lebel committed Feb 13, 2015
1 parent ec285ff commit d956ef1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Sources/MODClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ - (void)dealloc
self.operationQueue = nil;
self.mongoQueries = nil;
self.sshMapping = nil;
mongoc_client_destroy(self.mongocClient);
if (self.mongocClient) {
mongoc_client_destroy(self.mongocClient);
}
MOD_SUPER_DEALLOC();
}

Expand Down Expand Up @@ -304,7 +306,9 @@ - (MODReadPreferences *)readPreferences

- (void)setReadPreferences:(MODReadPreferences *)readPreferences
{
mongoc_client_set_read_prefs(self.mongocClient, self.mongocReadPreferences);
if (self.mongocClient) {
mongoc_client_set_read_prefs(self.mongocClient, self.mongocReadPreferences);
}
}

- (MODSSLOptions *)sslOptions
Expand All @@ -319,7 +323,9 @@ - (void)setSslOptions:(MODSSLOptions *)sslOptions
[sslOptions getMongocSSLOpt:&mongocSSLOptions];
MOD_RELEASE(_sslOptions);
_sslOptions = MOD_RETAIN(sslOptions);
mongoc_client_set_ssl_opts(self.mongocClient, &mongocSSLOptions);
if (self.mongocClient != NULL) {
mongoc_client_set_ssl_opts(self.mongocClient, &mongocSSLOptions);
}
}

- (MODWriteConcern *)writeConcern
Expand All @@ -329,7 +335,9 @@ - (MODWriteConcern *)writeConcern

- (void)setWriteConcern:(MODWriteConcern *)writeConcern
{
mongoc_client_set_write_concern(self.mongocClient, writeConcern.mongocWriteConcern);
if (self.mongocClient != NULL) {
mongoc_client_set_write_concern(self.mongocClient, writeConcern.mongocWriteConcern);
}
}

@end

0 comments on commit d956ef1

Please sign in to comment.