Skip to content

Commit

Permalink
Bug 66425: Avoid a ClassCastException found via oss-fuzz
Browse files Browse the repository at this point in the history
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=62170

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912252 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
centic9 committed Sep 11, 2023
1 parent e666d37 commit 481c00b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,11 @@ protected CTGroupShape getSpTree(){
if(sp.length == 0) {
throw new IllegalStateException("CTGroupShape was not found");
}
_spTree = (CTGroupShape)sp[0];
XmlObject xmlObject = sp[0];
if (!(xmlObject instanceof CTGroupShape)) {
throw new IllegalArgumentException("Had unexpected type of entry: " + xmlObject.getClass());
}
_spTree = (CTGroupShape) xmlObject;
}
return _spTree;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ public XSLFTheme getTheme(){
*/
@Override
public XSLFBackground getBackground() {
CTBackground bg = _slide.getCSld().getBg();
if(bg != null) {
return new XSLFBackground(bg, this);
if(_slide.getCSld() != null &&
_slide.getCSld().getBg() != null) {
return new XSLFBackground(_slide.getCSld().getBg(), this);
} else {
return getMasterSheet().getBackground();
}
Expand Down
Binary file not shown.
Binary file modified test-data/spreadsheet/stress.xls
Binary file not shown.

0 comments on commit 481c00b

Please sign in to comment.