diff --git a/src/core/lib/support/env_windows.c b/src/core/lib/support/env_windows.c index 652eeb61c67..a6499543f81 100644 --- a/src/core/lib/support/env_windows.c +++ b/src/core/lib/support/env_windows.c @@ -43,7 +43,10 @@ char *gpr_getenv(const char *name) { DWORD ret; ret = GetEnvironmentVariable(tname, NULL, 0); - if (ret == 0) return NULL; + if (ret == 0) { + gpr_free(tname); + return NULL; + } size = ret * (DWORD)sizeof(TCHAR); tresult = gpr_malloc(size); ret = GetEnvironmentVariable(tname, tresult, size);