提交 50dd8b08 编写于 作者: R rupashka

6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources

Reviewed-by: malenkov
上级 360a1536
......@@ -693,6 +693,7 @@ final class Win32ShellFolder2 extends ShellFolder {
ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
long pEnumObjects = getEnumObjects(includeHiddenFiles);
if (pEnumObjects != 0) {
try {
long childPIDL;
int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
do {
......@@ -715,8 +716,10 @@ final class Win32ShellFolder2 extends ShellFolder {
releasePIDL(childPIDL);
}
} while (childPIDL != 0 && !Thread.currentThread().isInterrupted());
} finally {
releaseEnumObjects(pEnumObjects);
}
}
return Thread.currentThread().isInterrupted()
? new File[0]
: list.toArray(new ShellFolder[list.size()]);
......
......@@ -79,9 +79,12 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
// Shouldn't happen but watch for it anyway
throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found");
}
Win32ShellFolder2 folder = createShellFolderFromRelativePIDL(parent, pIDL);
try {
return createShellFolderFromRelativePIDL(parent, pIDL);
} finally {
Win32ShellFolder2.releasePIDL(pIDL);
return folder;
}
}
static Win32ShellFolder2 createShellFolderFromRelativePIDL(Win32ShellFolder2 parent, long pIDL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册