jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
286 stars 65 forks source link

Avoid memory leak within `R_mongo_collection_find` #160

Closed MartinNowack closed 5 years ago

MartinNowack commented 5 years ago

R_mongo_collection_find leaks memory as mongoc_read_prefs_new(MONGOC_READ_PRIMARY) is not cleaned up. Anyway, MONGOC_READ_PRIMARY is the default (http://mongoc.org/libmongoc/current/mongoc_read_prefs_t.html). 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.

jeroen commented 5 years ago

Thanks!