win32: Fix handle leak apr_shm_create() implementation.
* shmem/win32/shm.c
(can_create_global_maps): Close thread/process token after checking for
privilege.
@@ -87,10 +87,12 @@ static int can_create_global_maps(void)
ok = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken);
}
- if (ok) {
- ok = LookupPrivilegeValue(NULL, SE_CREATE_GLOBAL_NAME, &priv_id);
+ if (!ok) {
+ return 0;
}
+ ok = LookupPrivilegeValue(NULL, SE_CREATE_GLOBAL_NAME, &priv_id);
+
if (ok) {
privs.PrivilegeCount = 1;
privs.Control = PRIVILEGE_SET_ALL_NECESSARY;
@@ -99,6 +101,8 @@ static int can_create_global_maps(void)
ok = PrivilegeCheck(hToken, &privs, &has_priv);
}
+ CloseHandle(hToken);
+
if (ok && !has_priv) {
return 0;
}
