Fixed several memory leaks.
This commit is contained in:
Родитель
f4ba59d29b
Коммит
65d4cbcb11
10
src/mongo.c
10
src/mongo.c
|
@ -217,7 +217,6 @@ void mongo_replset_init_conn( mongo_connection* conn, const char* name ) {
|
|||
memcpy( conn->replset->name, name, strlen( name ) + 1 );
|
||||
|
||||
conn->primary = bson_malloc( sizeof( mongo_host_port ) );
|
||||
conn->primary = NULL;
|
||||
|
||||
conn->err = 0;
|
||||
conn->errstr = NULL;
|
||||
|
@ -358,6 +357,7 @@ static int mongo_replset_check_host( mongo_connection* conn ) {
|
|||
if( bson_find( &it, &out, "setName" ) ) {
|
||||
set_name = bson_iterator_string( &it );
|
||||
if( strcmp( set_name, conn->replset->name ) != 0 ) {
|
||||
bson_destroy( &out );
|
||||
return mongo_conn_bad_set_name;
|
||||
}
|
||||
}
|
||||
|
@ -838,12 +838,12 @@ int mongo_cursor_destroy(mongo_cursor* cursor){
|
|||
data = mongo_data_append64(data, &cursor->mm->fields.cursorID);
|
||||
|
||||
result = mongo_message_send(conn, mm);
|
||||
|
||||
free(cursor->mm);
|
||||
free((void*)cursor->ns);
|
||||
free(cursor);
|
||||
}
|
||||
|
||||
free(cursor->mm);
|
||||
free((void*)cursor->ns);
|
||||
free(cursor);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,10 @@ int test_connect( const char* set_name ) {
|
|||
mongo_replset_add_seed( conn, TEST_SERVER, SEED_START_PORT + 1 );
|
||||
mongo_replset_add_seed( conn, TEST_SERVER, SEED_START_PORT );
|
||||
|
||||
if( (res = mongo_replset_connect( conn )) ) {
|
||||
mongo_destroy( conn );
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
mongo_disconnect( conn );
|
||||
return mongo_reconnect( conn );
|
||||
}
|
||||
res = mongo_replset_connect( conn );
|
||||
mongo_destroy( conn );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int test_reconnect( const char* set_name ) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче