Bug 66425: Avoid exceptions found via poi-fuzz

Prevent a NullPointerException

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66386

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2024-04-17 18:15:38 +00:00
parent 51637fcc43
commit c4e8388742
3 changed files with 3 additions and 2 deletions

View File

@ -63,9 +63,10 @@ public final class XSSFGraphicFrame extends XSSFShape {
for (int i = 0; i < nodes.getLength(); i++) { for (int i = 0; i < nodes.getLength(); i++) {
final Node node = nodes.item(i); final Node node = nodes.item(i);
// if the frame references a chart, associate the chart with this instance // if the frame references a chart, associate the chart with this instance
if (node.getNodeName().equals("c:chart")) { Node namedItem = node.getAttributes().getNamedItem("r:id");
if (node.getNodeName().equals("c:chart") && namedItem != null) {
// this better succeed or the document is invalid // this better succeed or the document is invalid
POIXMLDocumentPart relation = drawing.getRelationById(node.getAttributes().getNamedItem("r:id").getNodeValue()); POIXMLDocumentPart relation = drawing.getRelationById(namedItem.getNodeValue());
// Do XWPF charts need similar treatment? // Do XWPF charts need similar treatment?
if (relation instanceof XSSFChart) { if (relation instanceof XSSFChart) {
((XSSFChart) relation).setGraphicFrame(this); ((XSSFChart) relation).setGraphicFrame(this);

Binary file not shown.