Skip to content

Commit

Permalink
Fix Infinite Loop in Multicell with Auto Page Breaks Off (#473)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ssigwart and nicolaasuni authored Aug 12, 2022
1 parent 56e5dfd commit 5596537
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -6495,14 +6495,16 @@ public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $st
$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']);
Expand Down Expand Up @@ -6700,14 +6702,16 @@ public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $st
}
// 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'];
Expand Down

0 comments on commit 5596537

Please sign in to comment.