Lionel Debroux : advapi32/tests: Fix memory leaks (found by Smatch).

Alexandre Julliard julliard at winehq.org
Wed Oct 3 06:08:19 CDT 2007


Module: wine
Branch: master
Commit: 40c66b8977367103446e699741c8805eff7fc19b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=40c66b8977367103446e699741c8805eff7fc19b

Author: Lionel Debroux <lionel_debroux at yahoo.fr>
Date:   Tue Oct  2 08:59:02 2007 +0200

advapi32/tests: Fix memory leaks (found by Smatch).

---

 dlls/advapi32/tests/security.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 6426f84..a17931e 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -719,6 +719,7 @@ static void test_AccessCheck(void)
     if(!res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
     {
         skip("ACLs not implemented - skipping tests\n");
+        HeapFree(GetProcessHeap(), 0, Acl);
         return;
     }
     ok(res, "InitializeAcl failed with error %d\n", GetLastError());
@@ -1540,6 +1541,7 @@ static void test_process_security(void)
     if (!res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
     {
         skip("ACLs not implemented - skipping tests\n");
+        HeapFree(GetProcessHeap(), 0, Acl);
         return;
     }
     ok(res, "InitializeAcl failed with error %d\n", GetLastError());
@@ -1547,7 +1549,11 @@ static void test_process_security(void)
     /* get owner from the token we might be running as a user not admin */
     res = OpenProcessToken( GetCurrentProcess(), MAXIMUM_ALLOWED, &token );
     ok(res, "OpenProcessToken failed with error %d\n", GetLastError());
-    if (!res) return;
+    if (!res)
+    {
+        HeapFree(GetProcessHeap(), 0, Acl);
+        return;
+    }
 
     res = GetTokenInformation( token, TokenOwner, owner, sizeof(owner), &tmp );
     ok(res, "GetTokenInformation failed with error %d\n", GetLastError());
@@ -1557,7 +1563,11 @@ static void test_process_security(void)
     UsersSid = ((TOKEN_PRIMARY_GROUP*)group)->PrimaryGroup;
 
     CloseHandle( token );
-    if (!res) return;
+    if (!res)
+    {
+        HeapFree(GetProcessHeap(), 0, Acl);
+        return;
+    }
 
     res = AddAccessDeniedAce(Acl, ACL_REVISION, PROCESS_VM_READ, AdminSid);
     ok(res, "AddAccessDeniedAce failed with error %d\n", GetLastError());
@@ -2100,6 +2110,7 @@ static void test_PrivateObjectSecurity(void)
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected error ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
 
     LocalFree(sec);
+    HeapFree(GetProcessHeap(), 0, buf);
 }
 #undef CHECK_RESULT_AND_FREE
 




More information about the wine-cvs mailing list