diff options
author | Chris Bowditch <cbowditch@apache.org> | 2023-03-13 10:56:44 +0000 |
---|---|---|
committer | Chris Bowditch <cbowditch@apache.org> | 2023-03-13 10:56:44 +0000 |
commit | 2a73338d3424e9907b46a19f2288d61c9f885006 (patch) | |
tree | 464f918b7752b46a1916ba194fe49cb78e85b577 | |
parent | 96a114cb7b8c23835b3aa4205b56c88ba5e7c6c3 (diff) | |
download | xmlgraphics-fop-2a73338d3424e9907b46a19f2288d61c9f885006.tar.gz xmlgraphics-fop-2a73338d3424e9907b46a19f2288d61c9f885006.zip |
Add fix for NPE related to FOP-3098 by Jeremias Maerki
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java | 1 | ||||
-rw-r--r-- | fop/test/layoutengine/standard-testcases/list-block_npe_bug_empty_2nd_block.xml | 57 |
2 files changed, 58 insertions, 0 deletions
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> + |