Skip to content

Commit bd80bc8

Browse files
committed
test_framework_getenv fixes for win32
1 parent 7aaed83 commit bd80bc8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

tests/test-libmongoc.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,14 @@ static char *
131131
test_framework_getenv (const char *name)
132132
{
133133
#ifdef _MSC_VER
134-
char buf[1024];
135-
size_t buflen;
134+
char buf[1024];
135+
size_t buflen;
136136

137-
if (0 != getenv_s (&buflen, buf, sizeof buf, name)) {
138-
bson_strncpy (buf, "localhost", sizeof buf);
139-
return bson_strdup (buf);
140-
} else {
141-
return NULL;
142-
}
137+
if ((0 == getenv_s (&buflen, buf, sizeof buf, name)) && buflen) {
138+
return bson_strdup (buf);
139+
} else {
140+
return NULL;
141+
}
143142
#else
144143

145144
if (getenv (name)) {

0 commit comments

Comments
 (0)