Merge pull request #13169 from kkm000/fix-memleak-windows-getenv-backport

Fix Windows's memory leak in v1.7.x
pull/13170/merge
Jan Tattermusch 7 years ago committed by GitHub
commit 444d18f11d
  1. 5
      src/core/lib/support/env_windows.c

@ -43,7 +43,10 @@ char *gpr_getenv(const char *name) {
DWORD ret; DWORD ret;
ret = GetEnvironmentVariable(tname, NULL, 0); ret = GetEnvironmentVariable(tname, NULL, 0);
if (ret == 0) return NULL; if (ret == 0) {
gpr_free(tname);
return NULL;
}
size = ret * (DWORD)sizeof(TCHAR); size = ret * (DWORD)sizeof(TCHAR);
tresult = gpr_malloc(size); tresult = gpr_malloc(size);
ret = GetEnvironmentVariable(tname, tresult, size); ret = GetEnvironmentVariable(tname, tresult, size);

Loading…
Cancel
Save