Crash when cloning a cell

Hello Aspose,

I get a NullRefException when cloning a cell (Cell.Clone()).
To reproduce please try this:

 private static string CellCloneBug(Page page)
        {
            var t = new Table();
            var r = t.Rows.Add();
            var c = r.Cells.Add();
            c.Paragraphs.Add(null);
            c.Clone();
            page.Paragraphs.Add(t);                
            return Path.Combine(myDataDir, "CellCloneBug.pdf");
        }

This leads to a crash when saving a document or calling Document.ProcessParagraphs()

Regards
Gerd

@Gerd
I tested a bit, it seems that problem lies in c.Paragraphs.Add(null);
There should be some kind of text fragment that can be cloned
The following seems to work fine

private static void CellCloneBug()
{
    var pdfDocument = new Document();
    var page = pdfDocument.Pages.Add();
    var t = new Table();
    var r = t.Rows.Add();
    var c = r.Cells.Add();
    c.Paragraphs.Add(new TextFragment("Sample text"));
            
    r.Cells.Add((Cell)c.Clone());
    page.Paragraphs.Add(t);
    pdfDocument.Save(OutputFolder + "CellCloneBug.pdf");
}

Hello,
sure you are right. But it was only for demonstration.

But when I look into other *.Add(xyz) interfaces, they raise an exception when adding a null reference. I’m fine with that.

But if it should be possible to add a null-reference to a cell’s paragraphs then a following *.Clone() should not crash afterwards. This is best practice.

The crash will also happen when saving the PDF document and the root cause is very hard to find.

Regards
Gerd

@Gerd
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-58838

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

That’s fair, thank you for pointing that out
I’ll add task for development team to fix this issue