tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.18k stars 1.51k forks source link

Potential bug in rollbackTransaction() #497

Open ClausScherschel opened 2 years ago

ClausScherschel commented 2 years ago

When rolling back a transaction using rollbackTransaction(true), member of the preserved object copy (in member $this->objcopy) seem to be destroyed, too. This leads to $this->dpi getting unset, which, in a later AddPage() results in a division by zero exception in setPageOrientation():

$this->w = ($this->wPt / $this->k);
$this->h = ($this->hPt / $this->k);

because $this->k is calculated based on $this-dpi which is null after _destroy().

When using $objcopy = clone $this->objcopy; in rollbackTransaction() instead of $objcopy = $this->objcopy;

processing PDF is continued successfully. It seems, that when creating the object copy in startTransaction(), the clone actually isn't a clone but a reference.

Bug is present up to the latest version.

Best regards, Claus.