copy_to_excluding(src, dst, key, ...) appears to be unusable

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Critical - P2
    • None
    • Affects Version/s: 1.3.1
    • Component/s: libbson
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      copy_to_excluding(src, dst, key, ...) cannot be used because of BSON_ASSERT(dst) demands that bson_t *dst = bson_new()
      which will then create a memory leak since it malloc a second bson_t.

      ie.
      bson_t *dst;
      copy_to_excluding(src, dst, key, ...) // prints error message
      ...
      bson_destroy(dst);

      bson_t *dst = bson_new()
      copy_to_excluding(src, dst, key, ...) // no error message but memory leak
      ...
      bson_destroy(dst);

      copy_to_excluding_noinit(src, dst, key, ...) is the only possible non-leaking alternative as it doesnt malloc the second bson_t.

            Assignee:
            A. Jesse Jiryu Davis
            Reporter:
            adrian
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: