summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-10-07 22:12:58 +0000
committerDominik Stadler <centic@apache.org>2023-10-07 22:12:58 +0000
commite67006151861706a474bfc117969906b6d001baa (patch)
tree6bb7cdf2bb5f7ef82f8905f2bc6ed83f006349b1
parent2bd84bf25c816e7aed55fe70dca765a73cdde3bb (diff)
downloadpoi-e67006151861706a474bfc117969906b6d001baa.tar.gz
poi-e67006151861706a474bfc117969906b6d001baa.zip
Bug 66425: Avoid exceptions found via poi-fuzz
Fix check after commit fcaac5073716b98cba26c0655f06f20e310fd85e so that other IndexOutOfBoundsExceptions are still thrown out Also free resources when throwing an exception in the constructor git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912799 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
index f74e6b0dbb..73d05fa187 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
@@ -63,8 +63,16 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
setRandomAccessWindowSize(randomAccessWindowSize);
try {
_autoSizeColumnTracker = new AutoSizeColumnTracker(this);
- } catch (UnsatisfiedLinkError | InternalError e) {
- LOG.atWarn().log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS", e);
+ } catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError |
+ // thrown when no fonts are available in the workbook
+ IndexOutOfBoundsException e) {
+ // only handle special NoClassDefFound
+ if (!e.getMessage().contains("X11FontManager")) {
+ throw e;
+ }
+ LOG.atWarn()
+ .withThrowable(e)
+ .log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS");
}
}
@@ -99,9 +107,21 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
} catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError |
// thrown when no fonts are available in the workbook
IndexOutOfBoundsException e) {
+ // only handle special NoClassDefFound
+ if (!e.getMessage().contains("X11FontManager")) {
+ // close temporary resources when throwing exception in the constructor
+ _writer.close();
+
+ throw e;
+ }
LOG.atWarn()
.withThrowable(e)
.log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS");
+ } catch (Throwable e) {
+ // close temporary resources when throwing exception in the constructor
+ _writer.close();
+
+ throw e;
}
}