diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfPTable.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfPTable.java index df82d1539..f017e8270 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfPTable.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfPTable.java @@ -654,8 +654,12 @@ public PdfPCell addCell(String text) { * Adds a nested table. * * @param table the table to be added to the cell + * @throws DocumentException if table tries to add itself */ - public PdfPCell addCell(PdfPTable table) { + public PdfPCell addCell(PdfPTable table) throws DocumentException { + if (table == this) { + throw new DocumentException("unable.to.add.self.to.table.contents"); + } defaultCell.setTable(table); addCell(defaultCell); defaultCell.setTable(null);