Skip to content

Commit

Permalink
Avoid memory leak within R_mongo_collection_find (#160)
Browse files Browse the repository at this point in the history
This patch avoids the leakage by not allocating the memory in the first place but instead using `NULL` for `mongoc_collection_find_with_opts` to use the default values.
  • Loading branch information
MartinNowack authored and jeroen committed Oct 22, 2018
1 parent 85b874c commit 8f29f1e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/collection.c
Expand Up @@ -173,8 +173,7 @@ SEXP R_mongo_collection_find(SEXP ptr_col, SEXP ptr_query, SEXP ptr_opts) {
mongoc_collection_t *col = r2col(ptr_col);
bson_t *query = r2bson(ptr_query);
bson_t *opts = r2bson(ptr_opts);
mongoc_read_prefs_t * readpref = mongoc_read_prefs_new(MONGOC_READ_PRIMARY);
mongoc_cursor_t *c = mongoc_collection_find_with_opts(col, query, opts, readpref);
mongoc_cursor_t *c = mongoc_collection_find_with_opts(col, query, opts, NULL);
return cursor2r(c, ptr_col);
}

Expand Down

0 comments on commit 8f29f1e

Please sign in to comment.