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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 1.3.1
    • Component/s: libbson
    • Labels:
      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:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            adrianb adrian
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: