Skip to content

Commit d62b610

Browse files
committed
CDRIVER-2933 fix leak in test-conveniences
1 parent 287f34c commit d62b610

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libmongoc/tests/test-conveniences.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,18 +639,21 @@ match_json (const bson_t *doc,
639639
matches = match_bson_with_ctx (doc, pattern, &ctx);
640640

641641
if (!matches) {
642+
char *as_string =
643+
doc ? bson_as_canonical_extended_json (doc, NULL) : NULL;
642644
fprintf (stderr,
643645
"ASSERT_MATCH failed with document:\n\n"
644646
"%s\n"
645647
"pattern:\n%s\n"
646648
"%s\n"
647649
"%s:%d %s()\n",
648-
doc ? bson_as_canonical_extended_json (doc, NULL) : "{}",
650+
as_string ? as_string : "{}",
649651
double_quoted,
650652
ctx.errmsg,
651653
filename,
652654
lineno,
653655
funcname);
656+
bson_free (as_string);
654657
}
655658

656659
bson_destroy (pattern);

0 commit comments

Comments
 (0)