From 169018be010d35a91b10db9c39844d8e9b3de9cb Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Tue, 12 Jul 2011 00:37:45 +0000 Subject: [PATCH] NPE check git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145405 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hwpf/usermodel/TableRow.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java index 16a2967bb..0d861dac8 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java @@ -174,12 +174,15 @@ public final class TableRow extends Range cells.add( tableCell ); } - TableCell lastCell = cells.get( cells.size() - 1 ); - if ( lastCell.numParagraphs() == 1 - && ( lastCell.getParagraph( 0 ).isTableRowEnd() ) ) + if ( !cells.isEmpty() ) { - // remove "fake" cell - cells.remove( cells.size() - 1 ); + TableCell lastCell = cells.get( cells.size() - 1 ); + if ( lastCell.numParagraphs() == 1 + && ( lastCell.getParagraph( 0 ).isTableRowEnd() ) ) + { + // remove "fake" cell + cells.remove( cells.size() - 1 ); + } } if ( cells.size() != expectedCellsCount )