This is an automated email from the ASF dual-hosted git repository.

centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git

commit 1fc4f9e3b731a3ead0e28b81a63e395198dc8708
Author: Dominik Stadler <[email protected]>
AuthorDate: Sat Jan 10 17:27:47 2026 +0100

    Avoid ClastCastException when handling a broken ppt file
---
 .../java/org/apache/poi/hslf/usermodel/HSLFFill.java   |  11 +++++------
 .../java/org/apache/poi/hslf/usermodel/HSLFShape.java  |   6 +++---
 .../119877_all type background_save_by_AOO.ppt         | Bin 0 -> 932864 bytes
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java
index 9847155d50..2a565e281c 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.logging.log4j.Logger;
+import org.apache.poi.ddf.EscherProperty;
 import org.apache.poi.logging.PoiLogManager;
 import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherArrayProperty;
@@ -217,7 +218,7 @@ public final class HSLFFill {
     /**
      * The shape this background applies to
      */
-    private HSLFShape shape;
+    private final HSLFShape shape;
 
     /**
      * Construct a {@code Fill} object for a shape.
@@ -457,7 +458,6 @@ public final class HSLFFill {
         }
     }
 
-    @SuppressWarnings("resource")
     EscherBSERecord getEscherBSERecord(int idx){
         HSLFSheet sheet = shape.getSheet();
         if(sheet == null) {
@@ -560,11 +560,10 @@ public final class HSLFFill {
     /**
      * {@code PictureData} object used in a texture, pattern of picture fill.
      */
-    @SuppressWarnings("resource")
     public HSLFPictureData getPictureData(){
         AbstractEscherOptRecord opt = shape.getEscherOptRecord();
-        EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, 
EscherPropertyTypes.FILL__PATTERNTEXTURE);
-        if (p == null) {
+        EscherProperty p = HSLFShape.getEscherProperty(opt, 
EscherPropertyTypes.FILL__PATTERNTEXTURE);
+        if (!(p instanceof EscherSimpleProperty)) {
             return null;
         }
 
@@ -575,7 +574,7 @@ public final class HSLFFill {
         EscherContainerRecord dggContainer = 
doc.getPPDrawingGroup().getDggContainer();
         EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, 
EscherContainerRecord.BSTORE_CONTAINER);
 
-        int idx = p.getPropertyValue();
+        int idx = ((EscherSimpleProperty)p).getPropertyValue();
         if (idx == 0){
             LOG.atWarn().log("no reference to picture data found ");
         } else {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java
index b234a80833..e5c599ada3 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java
@@ -266,7 +266,7 @@ public abstract class HSLFShape implements 
Shape<HSLFShape,HSLFTextParagraph> {
      * @return escher property or {@code null} if not found.
      */
     public static <T extends EscherProperty> T 
getEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type){
-        return (opt == null) ? null : opt.lookup(type);
+        return opt == null ? null : opt.lookup(type);
     }
 
     /**
@@ -659,9 +659,9 @@ public abstract class HSLFShape implements 
Shape<HSLFShape,HSLFTextParagraph> {
     }
 
     /**
-     * Search for EscherClientDataRecord, if found, convert its contents into 
an array of HSLF records
+     * Search for EscherClientDataRecord, if found, convert its contents into 
a list of HSLF records
      *
-     * @return an array of HSLF records contained in the shape's 
EscherClientDataRecord or {@code null}
+     * @return a list of HSLF records contained in the shape's 
EscherClientDataRecord or {@code null}
      */
     protected List<? extends Record> getClientRecords() {
         HSLFEscherClientDataRecord clientData = getClientData(false);
diff --git a/test-data/slideshow/119877_all type background_save_by_AOO.ppt 
b/test-data/slideshow/119877_all type background_save_by_AOO.ppt
new file mode 100644
index 0000000000..28cfff121d
Binary files /dev/null and b/test-data/slideshow/119877_all type 
background_save_by_AOO.ppt differ


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to