Skip to content

Commit

Permalink
Avoid memory leak with in R_mongo_get_default_database (#159)
Browse files Browse the repository at this point in the history
Adds the proper call to avoid a memory leak.
  • Loading branch information
MartinNowack authored and jeroen committed Oct 22, 2018
1 parent 8f29f1e commit 26df60d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/collection.c
Expand Up @@ -11,7 +11,9 @@ SEXP R_mongo_get_default_database(SEXP ptr_client) {
mongoc_client_t *client = r2client(ptr_client);
mongoc_database_t *db = mongoc_client_get_default_database(client);
if(db){
return Rf_mkString(mongoc_database_get_name(db));
SEXP out = Rf_mkString(mongoc_database_get_name(db));
mongoc_database_destroy(db);
return out;
} else {
return R_NilValue;
}
Expand Down

0 comments on commit 26df60d

Please sign in to comment.