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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            Harris Kaufmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: