Skip to content

Commit 5411f2c

Browse files
committed
leaks in tests
1 parent bbf4d95 commit 5411f2c

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

tests/TestSuite.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ static void
502502
TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */
503503
FILE *stream) /* IN */
504504
{
505+
char *uri_str = test_framework_get_uri_str ();
506+
505507
#ifdef _WIN32
506508
# define INFO_BUFFER_SIZE 32767
507509

@@ -539,7 +541,7 @@ TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */
539541
" \"fork\": \"%s\"\n"
540542
" },\n"
541543
" \"tests\": [\n",
542-
test_framework_get_uri_str (),
544+
uri_str,
543545
test_framework_is_mongos () ? "true" : "false",
544546
major_version, minor_version, build,
545547
si.dwProcessorType,
@@ -583,7 +585,7 @@ TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */
583585
" \"fork\": \"%s\"\n"
584586
" },\n"
585587
" \"tests\": [\n",
586-
test_framework_get_uri_str (),
588+
uri_str,
587589
test_framework_is_mongos () ? "true" : "false",
588590
u.sysname,
589591
u.release,
@@ -595,6 +597,8 @@ TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */
595597
#endif
596598

597599
fflush (stream);
600+
601+
bson_free (uri_str);
598602
}
599603

600604

tests/test-libmongoc.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,15 @@ test_framework_get_uri_str_no_auth (const char *database_name)
657657
char *
658658
test_framework_get_uri_str ()
659659
{
660-
return test_framework_add_user_password_from_env (
661-
test_framework_get_uri_str_no_auth (NULL));
660+
char *uri_str_no_auth;
661+
char *uri_str;
662+
663+
uri_str_no_auth = test_framework_get_uri_str_no_auth (NULL);
664+
uri_str = test_framework_add_user_password_from_env (uri_str_no_auth);
665+
666+
bson_free (uri_str_no_auth);
667+
668+
return uri_str;
662669
}
663670

664671

tests/test-mongoc-topology.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ _test_server_selection (bool try_once)
180180
primary_pref, 15, &error);
181181
assert (request = mock_server_receives_ismaster (server));
182182
mock_server_replies_simple (request, secondary_response);
183+
request_destroy (request);
183184

184185
if (try_once) {
185186
/* selection fails without another ismaster call */

0 commit comments

Comments
 (0)