Uploaded image for project: 'Libmongocrypt'
  1. Libmongocrypt
  2. MONGOCRYPT-554

_fle2_finalize is missing calls to bson_destroy in an error case / double-initializing bson_t

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.7.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed

      In _fle2_finalize in mongocrypt-ctx-encrypt.c, there are two potential  memory leak errors that occur:

      1. The error case on line 1663 (as of commit 2ec9c3) should bson_destroy the converted and deleteTokens instances but is not currently doing so. (It also looks like the error case should return _mongocrypt_ctx_fail (ctx) instead of false in this case.)
      2. bson_copy_to on line 1617 (as of commit 2ec9c3) requires that the destination argument is an uninitialized bson_t (documentation) but line 1616 calls bson_init on the destination converted.

      —

      To reproduce, use

      mkdir cmake-build && cd cmake-build
      cmake ../
      make
      valgrind --leak-check=full ./test-mongocrypt 
      

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            zachary.espiritu@mongodb.com Zachary Espiritu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: