Fix Infinite Loop in Multicell with Auto Page Breaks Off (#473)

The updated places that used `AcceptPageBreak` assumed that a page break was added and increased X by the margin.  However, if the break wasn't added, it would put the text further to the right to the point that the width because so small or negative and no characters fit, causing an infinite loop.

Co-authored-by: Nicola Asuni <nicolaasuni@users.noreply.github.com>
This commit is contained in:
Stephen Sigwart 2022-08-12 03:29:02 -04:00 committed by GitHub
parent 56e5dfdf23
commit 5596537f8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6495,14 +6495,16 @@ class TCPDF {
$shy = false;
// account for margin changes
if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->inPageBody())) {
$this->AcceptPageBreak();
if ($this->rtl) {
$this->x -= $margin['R'];
} else {
$this->x += $margin['L'];
if ($this->AcceptPageBreak())
{
if ($this->rtl) {
$this->x -= $margin['R'];
} else {
$this->x += $margin['L'];
}
$this->lMargin += $margin['L'];
$this->rMargin += $margin['R'];
}
$this->lMargin += $margin['L'];
$this->rMargin += $margin['R'];
}
$w = $this->getRemainingWidth();
$wmax = ($w - $this->cell_padding['L'] - $this->cell_padding['R']);
@ -6700,14 +6702,16 @@ class TCPDF {
}
// account for margin changes
if ((($this->y + $this->lasth) > $this->PageBreakTrigger) AND ($this->inPageBody())) {
$this->AcceptPageBreak();
if ($this->rtl) {
$this->x -= $margin['R'];
} else {
$this->x += $margin['L'];
if ($this->AcceptPageBreak())
{
if ($this->rtl) {
$this->x -= $margin['R'];
} else {
$this->x += $margin['L'];
}
$this->lMargin += $margin['L'];
$this->rMargin += $margin['R'];
}
$this->lMargin += $margin['L'];
$this->rMargin += $margin['R'];
}
$w = $this->getRemainingWidth();
$wmax = $w - $this->cell_padding['L'] - $this->cell_padding['R'];