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

6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources

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