From 4c8edb1b4c25cffeaa1573f431e9931c1fc87042 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 30 Apr 2014 10:21:42 +0200 Subject: [PATCH] msi/tests: Fix a couple of memory leaks (valgrind). --- dlls/msi/tests/action.c | 8 +++++--- dlls/msi/tests/automation.c | 8 +++++--- dlls/msi/tests/install.c | 8 +++++--- dlls/msi/tests/msi.c | 8 +++++--- dlls/msi/tests/package.c | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/dlls/msi/tests/action.c b/dlls/msi/tests/action.c index 047854bca31..9f1651dd628 100644 --- a/dlls/msi/tests/action.c +++ b/dlls/msi/tests/action.c @@ -2255,20 +2255,22 @@ static void init_functionpointers(void) static BOOL is_process_limited(void) { SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group; + PSID Group = NULL; BOOL IsInGroup; HANDLE token; if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, &Group) || + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || !pCheckTokenMembership(NULL, Group, &IsInGroup)) { trace("Could not check if the current user is an administrator\n"); + FreeSid(Group); return FALSE; } + FreeSid(Group); + if (!IsInGroup) { /* Only administrators have enough privileges for these tests */ diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c index 242ec63d957..beed6fdcba8 100644 --- a/dlls/msi/tests/automation.c +++ b/dlls/msi/tests/automation.c @@ -230,20 +230,22 @@ static void init_functionpointers(void) static BOOL is_process_limited(void) { SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group; + PSID Group = NULL; BOOL IsInGroup; HANDLE token; if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, &Group) || + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || !pCheckTokenMembership(NULL, Group, &IsInGroup)) { trace("Could not check if the current user is an administrator\n"); + FreeSid(Group); return FALSE; } + FreeSid(Group); + if (!IsInGroup) { /* Only administrators have enough privileges for these tests */ diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index 603042affe1..2a9af8549e8 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -2043,20 +2043,22 @@ static void init_functionpointers(void) static BOOL is_process_limited(void) { SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group; + PSID Group = NULL; BOOL IsInGroup; HANDLE token; if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, &Group) || + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || !pCheckTokenMembership(NULL, Group, &IsInGroup)) { trace("Could not check if the current user is an administrator\n"); + FreeSid(Group); return FALSE; } + FreeSid(Group); + if (!IsInGroup) { /* Only administrators have enough privileges for these tests */ diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c index 1d63df56983..3897c24b0ca 100644 --- a/dlls/msi/tests/msi.c +++ b/dlls/msi/tests/msi.c @@ -175,20 +175,22 @@ static BOOL delete_pf(const char *rel_path, BOOL is_file) static BOOL is_process_limited(void) { SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group; + PSID Group = NULL; BOOL IsInGroup; HANDLE token; if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, &Group) || + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || !pCheckTokenMembership(NULL, Group, &IsInGroup)) { trace("Could not check if the current user is an administrator\n"); + FreeSid(Group); return FALSE; } + FreeSid(Group); + if (!IsInGroup) { /* Only administrators have enough privileges for these tests */ diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index d5c37eabe21..a0c0455f92d 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -88,20 +88,22 @@ static void init_functionpointers(void) static BOOL is_process_limited(void) { SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group; + PSID Group = NULL; BOOL IsInGroup; HANDLE token; if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, &Group) || + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || !pCheckTokenMembership(NULL, Group, &IsInGroup)) { trace("Could not check if the current user is an administrator\n"); + FreeSid(Group); return FALSE; } + FreeSid(Group); + if (!IsInGroup) { if (!AllocateAndInitializeSid(&NtAuthority, 2,