Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-446

Memory leak in mongoc_client_command_simple()

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.0
    • Affects Version/s: 1.0.2
    • Component/s: None
    • Labels:
      None

      when I call mongoc_database_get_collection_info() a new bson is created:
      https://github.com/mongodb/mongo-c-driver/blob/048c851919dc32c98b5f8a9a0270e69af9385db3/src/mongoc/mongoc-database.c#L741

      the bson correct. But, this bson is sent to mongoc_database_command_simple() and then to mongoc_client_command_simple()

      The issue is this bson is sent to bson_init() :
      https://github.com/mongodb/mongo-c-driver/blob/048c851919dc32c98b5f8a9a0270e69af9385db3/src/mongoc/mongoc-client.c#L1247

      so the flags of this bson changes from BSON_FLAG_INLINE to BSON_FLAG_INLINE | BSON_FLAG_STATIC

      So later when bson_destroy() is called, the buffer is not freed()

      I think bson_reinit() should be called instead. But I'm not sure. I'm not even sure if we need to call something on this bson.

            Assignee:
            mira.carey@mongodb.com Mira Carey
            Reporter:
            jeromelebel Jerome Lebel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: