diff options
author | Dominik Stadler <centic@apache.org> | 2023-08-05 12:13:13 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2023-08-05 12:13:13 +0000 |
commit | 57d746827f48710f094b09f5d4a24090be97d4fb (patch) | |
tree | fc3891203983c28f7b1d375370cfc10c35432f91 /poi-integration/src | |
parent | acf61f325f24307e6af7767f34e027aef81d4932 (diff) | |
download | poi-57d746827f48710f094b09f5d4a24090be97d4fb.tar.gz poi-57d746827f48710f094b09f5d4a24090be97d4fb.zip |
Bug 66425: Avoid a ClassCastException found via oss-fuzz
We try to avoid throwing ClassCastException but it was possible
to trigger one here with a specially crafted input-file
Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61162
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911459 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-integration/src')
-rw-r--r-- | poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java index 5897803e74..a9e10430ac 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/HPBFFileHandler.java @@ -45,22 +45,16 @@ public class HPBFFileHandler extends POIFSFileHandler { void test() throws Exception { File file = new File("test-data/publisher/SampleBrochure.pub"); - InputStream stream = new FileInputStream(file); - try { + try (InputStream stream = new FileInputStream(file)) { handleFile(stream, file.getPath()); - } finally { - stream.close(); } handleExtracting(file); - stream = new FileInputStream(file); - try { + try (InputStream stream = new FileInputStream(file)) { try (PublisherTextExtractor extractor = new PublisherTextExtractor(stream)) { assertNotNull(extractor.getText()); } - } finally { - stream.close(); } } |