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

Memory leak in mongoc_database_command_simple when passing in a reply object created by bson_new

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      The command `mongoc_database_command_simple` leaks memory, when passing in a reply object created by bson_new. This can easily be reproduced with a few lines on C code: https://gist.github.com/kamulos/92b9a270c9e6e36e512cfa43ec470c26

      I found this in a Rust wrapper of libmongoc: https://github.com/appsignal/mongo-rust-driver/issues/70

      The only cause I could find is that the `flags` are set to `BSON_FLAG_STATIC` in `bson_copy_to`. This prevents the pointer being freed in `bson_destroy`.
       

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            st4ck0v3rfl0w@gmail.com Harris Kaufmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: