You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by cb...@apache.org on 2023/03/13 10:57:16 UTC

[xmlgraphics-fop] branch main updated: Add fix for NPE related to FOP-3098 by Jeremias Maerki

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

cbowditch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-fop.git


The following commit(s) were added to refs/heads/main by this push:
     new 2a73338d3 Add fix for NPE related to FOP-3098 by Jeremias Maerki
2a73338d3 is described below

commit 2a73338d3424e9907b46a19f2288d61c9f885006
Author: Chris Bowditch <cb...@apache.org>
AuthorDate: Mon Mar 13 10:56:44 2023 +0000

    Add fix for NPE related to FOP-3098 by Jeremias Maerki
---
 .../fop/layoutmgr/list/ListItemLayoutManager.java  |  1 +
 .../list-block_npe_bug_empty_2nd_block.xml         | 57 ++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index a15e58ad4..9473db66c 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -498,6 +498,7 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage
                         && position.getLM() instanceof ListItemContentLayoutManager) {
                     position = position.getPosition();
                     if (position != null
+                            && position.getPosition() != null
                             && position.getLM() instanceof BlockLayoutManager) {
                         retval = new LeafPosition(position.getPosition().getLM(), 0);
                     }
diff --git a/fop/test/layoutengine/standard-testcases/list-block_npe_bug_empty_2nd_block.xml b/fop/test/layoutengine/standard-testcases/list-block_npe_bug_empty_2nd_block.xml
new file mode 100644
index 000000000..65547c838
--- /dev/null
+++ b/fop/test/layoutengine/standard-testcases/list-block_npe_bug_empty_2nd_block.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks triggered a NPE in
+      in ListItemLayoutManager.extractBlock() on a null Position due to an empty second block.
+    </p>
+  </info>
+  <fo>
+    <root xmlns="http://www.w3.org/1999/XSL/Format">
+    
+      <layout-master-set>
+        <simple-page-master master-name="a4" page-height="29.7cm" page-width="21cm">
+          <region-body/>
+        </simple-page-master>
+      </layout-master-set>
+      
+      <page-sequence master-reference="a4">
+        <flow flow-name="xsl-region-body">
+          <list-block provisional-distance-between-starts="20mm" provisional-label-separation="4mm">
+            <list-item>
+              <list-item-label end-indent="label-end()">
+                <block>1.1.</block>
+              </list-item-label>
+              <list-item-body start-indent="body-start()">
+                <block>blah blah</block>
+                <block/> <!-- Empty block here caused NPE in ListItemLayoutManager.extractBlock() on a null Position -->
+              </list-item-body>
+            </list-item>
+          </list-block>
+        </flow>
+      </page-sequence>
+    </root>
+  </fo>
+  <checks>
+    <eval expected="1" xpath="count(//pageViewport)"/>
+    <eval expected="1.1." xpath="//pageViewport[@nr=1]/descendant::text[1]"/>
+  </checks>
+</testcase>
+


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org