Skip to content

Commit

Permalink
MONGOCRYPT-554 fix cleanup in _fle2_finalize error case (#595)
Browse files Browse the repository at this point in the history
* add missing destroy and context fail on error

* remove unnecessary `bson_init`

`bson_copy_to` initializes the destination
  • Loading branch information
kevinAlbs committed Mar 14, 2023
1 parent b450387 commit 0caa1d3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/mongocrypt-ctx-encrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,6 @@ _fle2_finalize (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
/* If marked_cmd buffer is empty, there are no markings to encrypt. */
if (_mongocrypt_buffer_empty (&ectx->marked_cmd)) {
/* Append 'encryptionInformation' to the original command. */
bson_init (&converted);
bson_copy_to (&original_cmd_bson, &converted);
} else {
bson_t as_bson;
Expand Down Expand Up @@ -1649,7 +1648,9 @@ _fle2_finalize (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
moe_result result =
must_omit_encryptionInformation (command_name, &converted, ctx->status);
if (!result.ok) {
return false;
bson_destroy (&converted);
bson_destroy (deleteTokens);
return _mongocrypt_ctx_fail (ctx);
}

/* Append a new 'encryptionInformation'. */
Expand Down

0 comments on commit 0caa1d3

Please sign in to comment.