8207145: (fs) Native memory leak in WindowsNativeDispatcher.LookupPrivilegeValue0
Reviewed-by: alanb
This commit is contained in:
parent
1c976267be
commit
78f3c8a7d4
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -102,9 +102,8 @@ class WindowsSecurity {
|
|||||||
final boolean stopImpersontating = impersontating;
|
final boolean stopImpersontating = impersontating;
|
||||||
final boolean needToRevert = elevated;
|
final boolean needToRevert = elevated;
|
||||||
|
|
||||||
return new Privilege() {
|
return () -> {
|
||||||
@Override
|
try {
|
||||||
public void drop() {
|
|
||||||
if (token != 0L) {
|
if (token != 0L) {
|
||||||
try {
|
try {
|
||||||
if (stopImpersontating)
|
if (stopImpersontating)
|
||||||
@ -118,6 +117,8 @@ class WindowsSecurity {
|
|||||||
CloseHandle(token);
|
CloseHandle(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
LocalFree(pLuid);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2017, 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1043,8 +1043,11 @@ Java_sun_nio_fs_WindowsNativeDispatcher_LookupPrivilegeValue0(JNIEnv* env,
|
|||||||
if (pLuid == NULL) {
|
if (pLuid == NULL) {
|
||||||
JNU_ThrowInternalError(env, "Unable to allocate LUID structure");
|
JNU_ThrowInternalError(env, "Unable to allocate LUID structure");
|
||||||
} else {
|
} else {
|
||||||
if (LookupPrivilegeValueW(NULL, lpName, pLuid) == 0)
|
if (LookupPrivilegeValueW(NULL, lpName, pLuid) == 0) {
|
||||||
|
LocalFree(pLuid);
|
||||||
throwWindowsException(env, GetLastError());
|
throwWindowsException(env, GetLastError());
|
||||||
|
return (jlong)0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ptr_to_jlong(pLuid);
|
return ptr_to_jlong(pLuid);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user