pjfanning opened a new pull request, #1251:
URL: https://github.com/apache/poi/pull/1251
`HSLFSlideShowImpl(DirectoryNode, char[])` already closes the underlying
filesystem when parsing fails, so that `HSLFSlideShowImpl(String fileName)`
does not leak the file handle it opened:
```java
public HSLFSlideShowImpl(DirectoryNode dir, char[] password) throws
IOException {
super(handleDualStorage(dir));
try {
...
} catch (RuntimeException | IOException e) {
dir.getFileSystem().close();
throw e;
}
}
```
That cleanup does not cover `handleDualStorage`, which runs in the
`super(...)` argument and therefore completes before the constructor body — and
its try block — is entered.
`handleDualStorage` casts the `PP97_DUALSTORAGE` entry to `DirectoryNode`. A
malformed file where that entry is a document rather than a directory fails the
cast with a `ClassCastException` that escapes past the constructor's catch,
leaking the file handle opened by `new POIFSFileSystem(new File(fileName))`.
### Fix
Close the filesystem in `handleDualStorage` itself and rethrow the original
exception, matching what the constructor already does for the parsing stage.
The cast is deliberately left as-is rather than replaced with an explicit
type check, so the exception type callers see for a malformed file does not
change — this PR is only about releasing the handle.
No public signatures change, so there is nothing for MiMa to check. The 99
`org.apache.poi.hslf.*` test classes pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]