< prev index next >

src/java.base/windows/classes/sun/nio/fs/WindowsSecurity.java

Print this page
rev 51041 : imported patch 8207145-Memory-leak-in-WindowsNativeDispatcher

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -100,13 +100,12 @@
 
         final long token = hToken;
         final boolean stopImpersontating = impersontating;
         final boolean needToRevert = elevated;
 
-        return new Privilege() {
-            @Override
-            public void drop() {
+        return () -> {
+            try {
                 if (token != 0L) {
                     try {
                         if (stopImpersontating)
                             SetThreadToken(0L, 0L);
                         else if (needToRevert)

@@ -116,10 +115,12 @@
                         throw new AssertionError(x);
                     } finally {
                         CloseHandle(token);
                     }
                 }
+            } finally {
+                LocalFree(pLuid);
             }
         };
     }
 
     /**
< prev index next >