1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Fix some memory leaks and improve restricted token handling on Windows

The leaks have been detected by a Coverity run on Windows.  No backpatch
is done as the leaks are minor.

While on it, make restricted token creation more consistent in its error
handling by logging an error instead of a warning if missing
advapi32.dll, which was missing in the NT4 days.  Any modern platform
should have this DLL around.  Now, if the library is not there, an error
is still reported back to the caller, and nothing is done do there is no
behavior change done in this commit.

Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQApa9MG0foPkgPX87fipk=vhnF2Xfg+CfUyR08h4R7Mywg@mail.gmail.com
This commit is contained in:
Michael Paquier
2020-01-27 11:02:05 +09:00
parent 3ec20c7091
commit 10a525230f
3 changed files with 42 additions and 12 deletions

View File

@@ -4719,6 +4719,8 @@ retry:
if (cmdLine[sizeof(cmdLine) - 2] != '\0')
{
elog(LOG, "subprocess command line too long");
UnmapViewOfFile(param);
CloseHandle(paramHandle);
return -1;
}
@@ -4735,6 +4737,8 @@ retry:
{
elog(LOG, "CreateProcess call failed: %m (error code %lu)",
GetLastError());
UnmapViewOfFile(param);
CloseHandle(paramHandle);
return -1;
}
@@ -4750,6 +4754,8 @@ retry:
GetLastError())));
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
UnmapViewOfFile(param);
CloseHandle(paramHandle);
return -1; /* log made by save_backend_variables */
}